Errors building couchbase lite core android

I want to build couchbase lite core android on my unbuntu machine. However, after I run ./build_android, the following error occurs. How should I solve it?

~/dev-JiajieHuang/couchbase-lite-core/build_cmake ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86 ~/dev-JiajieHuang/couchbase-lite-core/build_cmake ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts
-- Android: Targeting API '16' with architecture 'x86', ABI 'x86', and processor 'i686'
-- Android: Selected Clang toolchain 'x86-clang' with GCC toolchain ''
-- The C compiler identification is Clang 8.0.2
-- The CXX compiler identification is Clang 8.0.2
-- Check for working C compiler: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_2261f/fast"
    /usr/bin/make -f CMakeFiles/cmTC_2261f.dir/build.make CMakeFiles/cmTC_2261f.dir/build
    make[1]: Entering directory '/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_2261f.dir/testCCompiler.c.o
    /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=i686-none-linux-android --gcc-toolchain=/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains//prebuilt/linux-x86_64 --sysroot=/home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot  -isystem /home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot/usr/include -isystem /home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot/usr/include/i686-linux-android  -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=16 -fexceptions  -g -fPIE   -o CMakeFiles/cmTC_2261f.dir/testCCompiler.c.o   -c /home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_2261f
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_2261f.dir/link.txt --verbose=1
    /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=i686-none-linux-android --gcc-toolchain=/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains//prebuilt/linux-x86_64 --sysroot=/home/jiajiehuang/Android/Sdk/ndk-bundle/platforms/android-16/arch-x86 -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=16 -fexceptions  -g  -fPIE -pie -Wl,--gc-sections -Wl,-z,nocopyreloc  CMakeFiles/cmTC_2261f.dir/testCCompiler.c.o  -o cmTC_2261f 
    /usr/bin/ld: cannot find -lgcc
    /usr/bin/ld: cannot find -lgcc
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    CMakeFiles/cmTC_2261f.dir/build.make:97: recipe for target 'cmTC_2261f' failed
    make[1]: *** [cmTC_2261f] Error 1
    make[1]: Leaving directory '/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_2261f/fast' failed
    make: *** [cmTC_2261f/fast] Error 2
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:47 (project)


-- Configuring incomplete, errors occurred!
See also "/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86/CMakeFiles/CMakeOutput.log".
See also "/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86/CMakeFiles/CMakeError.log".
make: *** No rule to make target 'LiteCore'.  Stop.
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86 ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86
Usage: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64/i686-linux-android/bin/strip <option(s)> in-file(s)
 Removes symbols and sections from files
 The options are:
  -I --input-target=<bfdname>      Assume input file is in format <bfdname>
  -O --output-target=<bfdname>     Create an output file in format <bfdname>
  -F --target=<bfdname>            Set both input and output format to <bfdname>
  -p --preserve-dates              Copy modified/access timestamps to the output
  -D --enable-deterministic-archives
                                   Produce deterministic output when stripping archives
  -U --disable-deterministic-archives
                                   Disable -D behavior (default)
  -R --remove-section=<name>       Also remove section <name> from the output
  -s --strip-all                   Remove all symbol and relocation information
  -g -S -d --strip-debug           Remove all debugging symbols & sections
     --strip-dwo                   Remove all DWO sections
     --strip-unneeded              Remove all symbols not needed by relocations
     --only-keep-debug             Strip everything but the debug information
  -N --strip-symbol=<name>         Do not copy symbol <name>
  -K --keep-symbol=<name>          Do not strip symbol <name>
     --keep-file-symbols           Do not strip file symbol(s)
  -w --wildcard                    Permit wildcard in symbol comparison
  -x --discard-all                 Remove all non-global symbols
  -X --discard-locals              Remove any compiler-generated symbols
  -v --verbose                     List all object files modified
  -V --version                     Display this program's version number
  -h --help                        Display this output
     --info                        List object formats & architectures supported
  -o <file>                        Place stripped output into <file>
/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64/i686-linux-android/bin/strip: supported targets: elf32-i386 elf32-iamcu a.out-i386-linux pei-i386 elf64-x86-64 elf32-x86-64 pei-x86-64 elf64-l1om elf64-k1om elf64-little elf64-big elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
rm: cannot remove 'libLiteCore.so': No such file or directory
make: *** No rule to make target 'LiteCore'.  Stop.
/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64/i686-linux-android/bin/objcopy: 'libLiteCore.so': No such file
/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64/i686-linux-android/bin/strip: 'libLiteCore.so': No such file
/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/x86-4.9/prebuilt/linux-x86_64/i686-linux-android/bin/objcopy: 'libLiteCore.so': No such file
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/x86
~/dev-JiajieHuang/couchbase-lite-core/build_cmake ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a ~/dev-JiajieHuang/couchbase-lite-core/build_cmake ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts
-- Android: Targeting API '16' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
-- Android: Selected Clang toolchain 'arm-linux-androideabi-clang' with GCC toolchain ''
-- The C compiler identification is Clang 8.0.2
-- The CXX compiler identification is Clang 8.0.2
-- Check for working C compiler: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_aed92/fast"
    /usr/bin/make -f CMakeFiles/cmTC_aed92.dir/build.make CMakeFiles/cmTC_aed92.dir/build
    make[1]: Entering directory '/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_aed92.dir/testCCompiler.c.o
    /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi --gcc-toolchain=/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains//prebuilt/linux-x86_64 --sysroot=/home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot  -isystem /home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot/usr/include -isystem /home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi  -march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=16 -fexceptions  -g -fPIE   -o CMakeFiles/cmTC_aed92.dir/testCCompiler.c.o   -c /home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_aed92
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_aed92.dir/link.txt --verbose=1
    /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi --gcc-toolchain=/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains//prebuilt/linux-x86_64 --sysroot=/home/jiajiehuang/Android/Sdk/ndk-bundle/platforms/android-16/arch-arm -march=armv7-a -mthumb -mfpu=vfpv3-d16 -mfloat-abi=softfp -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=16 -fexceptions  -g  -Wl,--fix-cortex-a8  -fPIE -pie -Wl,--gc-sections -Wl,-z,nocopyreloc  CMakeFiles/cmTC_aed92.dir/testCCompiler.c.o  -o cmTC_aed92 
    /usr/bin/ld: unrecognised emulation mode: armelf_linux_eabi
    Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    CMakeFiles/cmTC_aed92.dir/build.make:97: recipe for target 'cmTC_aed92' failed
    make[1]: *** [cmTC_aed92] Error 1
    make[1]: Leaving directory '/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_aed92/fast' failed
    make: *** [cmTC_aed92/fast] Error 2
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:47 (project)


-- Configuring incomplete, errors occurred!
See also "/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a/CMakeFiles/CMakeOutput.log".
See also "/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a/CMakeFiles/CMakeError.log".
make: *** No rule to make target 'LiteCore'.  Stop.
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a
xargs: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/binstrip: No such file or directory
rm: cannot remove 'libLiteCore.so': No such file or directory
make: *** No rule to make target 'LiteCore'.  Stop.
./strip.sh: line 16: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/binobjcopy: No such file or directory
./strip.sh: line 18: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/binstrip: No such file or directory
./strip.sh: line 20: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/binobjcopy: No such file or directory
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/armeabi-v7a
~/dev-JiajieHuang/couchbase-lite-core/build_cmake ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a ~/dev-JiajieHuang/couchbase-lite-core/build_cmake ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts
-- Android: Targeting API '21' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
-- Android: Selected Clang toolchain 'aarch64-linux-android-clang' with GCC toolchain ''
-- The C compiler identification is Clang 8.0.2
-- The CXX compiler identification is Clang 8.0.2
-- Check for working C compiler: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
-- Check for working C compiler: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- broken
CMake Error at /usr/share/cmake-3.10/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_fd1a5/fast"
    /usr/bin/make -f CMakeFiles/cmTC_fd1a5.dir/build.make CMakeFiles/cmTC_fd1a5.dir/build
    make[1]: Entering directory '/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_fd1a5.dir/testCCompiler.c.o
    /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android --gcc-toolchain=/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains//prebuilt/linux-x86_64 --sysroot=/home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot  -isystem /home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot/usr/include -isystem /home/jiajiehuang/Android/Sdk/ndk-bundle/sysroot/usr/include/aarch64-linux-android  -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=21 -fexceptions  -g -fPIE   -o CMakeFiles/cmTC_fd1a5.dir/testCCompiler.c.o   -c /home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_fd1a5
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_fd1a5.dir/link.txt --verbose=1
    /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android --gcc-toolchain=/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains//prebuilt/linux-x86_64 --sysroot=/home/jiajiehuang/Android/Sdk/ndk-bundle/platforms/android-21/arch-arm64 -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=21 -fexceptions  -g  -fPIE -pie -Wl,--gc-sections  CMakeFiles/cmTC_fd1a5.dir/testCCompiler.c.o  -o cmTC_fd1a5 
    /usr/bin/ld: unrecognised emulation mode: aarch64linux
    Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    CMakeFiles/cmTC_fd1a5.dir/build.make:97: recipe for target 'cmTC_fd1a5' failed
    make[1]: *** [cmTC_fd1a5] Error 1
    make[1]: Leaving directory '/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_fd1a5/fast' failed
    make: *** [cmTC_fd1a5/fast] Error 2
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:47 (project)


-- Configuring incomplete, errors occurred!
See also "/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a/CMakeFiles/CMakeOutput.log".
See also "/home/jiajiehuang/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a/CMakeFiles/CMakeError.log".
make: *** No rule to make target 'LiteCore'.  Stop.
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a
xargs: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/binstrip: No such file or directory
rm: cannot remove 'libLiteCore.so': No such file or directory
make: *** No rule to make target 'LiteCore'.  Stop.
./strip.sh: line 16: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/binobjcopy: No such file or directory
./strip.sh: line 18: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/binstrip: No such file or directory
./strip.sh: line 20: /home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/binobjcopy: No such file or directory
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/android/lib/arm64-v8a
~/dev-JiajieHuang/couchbase-lite-core/build_cmake ~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts
~/dev-JiajieHuang/couchbase-lite-core/build_cmake/scripts

Your problem is here:

/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android --gcc-toolchain=/home/jiajiehuang/Android/Sdk/ndk-bundle/toolchains//prebuilt/linux-x86_64 --sysroot=/home/jiajiehuang/Android/Sdk/ndk-bundle/platforms/android-21/arch-arm64 -funwind-tables -no-canonical-prefixes -D__ANDROID_API__=21 -fexceptions -g -fPIE -pie -Wl,–gc-sections CMakeFiles/cmTC_fd1a5.dir/testCCompiler.c.o -o cmTC_fd1a5
/usr/bin/ld: unrecognised emulation mode: aarch64linux
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386linux elf_l1om elf_k1om i386pep i386pe

Perhaps you mistyped the name of your architecture, somewhere?

Could you post a guide and troubleshooting of building couchbase lite core android ? On github there is only unix version guide.

The steps that you need to perform are in the (not official) script that you found. The cmake and make steps are the key. What version of the Android NDK are you using?

I have tried various NDKs. r15c, r16b, r17c, r18b, r19c, r20. And build only success with r15c and r20