Android-database-sqlcipher build fail

SQLCipher version:
4.4.3
android-database-sqlcipher:
4.4.3
ndk-r20
openssl - 1.1.1g

build fail log:

jiong@jiong:~/project/android-database-sqlcipher$ make build-release
./gradlew android-database-sqlcipher:bundleReleaseAar \
-PdebugBuild=false \
-PsqlcipherRoot="/home/jiong/project/sqlcipher" \
-PopensslRoot="/home/jiong/project/openssl" \
-PopensslAndroidLibRoot="/home/jiong/project/output" \
-PsqlcipherCFlags= "-DSQLITE_HAS_CODEC -DSQLITE_SOUNDEX -DHAVE_USLEEP=1 -DSQLITE_MAX_VARIABLE_NUMBER=99999 -DSQLITE_TEMP_STORE=3 -DSQLITE_THREADSAFE=1 -DSQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576 -DNDEBUG=1 -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1 -DSQLITE_ENABLE_LOAD_EXTENSION -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_UNLOCK_NOTIFY -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_STAT3 -DSQLITE_ENABLE_STAT4 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLCIPHER_CRYPTO_OPENSSL -DSQLITE_ENABLE_DBSTAT_VTAB" \
-PsqlcipherAndroidClientVersion="4.4.3"

> Task :android-database-sqlcipher:buildOpenSSL SKIPPED
/home/jiong/project/output/armeabi-v7a/libcrypto.a exists SKIPPED

> Task :android-database-sqlcipher:buildNative FAILED
SQLCIPHER_CFLAGS=
OPENSSL_DIR=/home/jiong/project/openssl
SQLCIPHER_DIR=/home/jiong/project/sqlcipher
SQLCIPHER_OTHER_CFLAGS=-DLOG_NDEBUG -fstack-protector-all
ANDROID_NATIVE_ROOT_DIR=/home/jiong/project/output
NDK_APP_PLATFORM=16
make[1]: Entering directory `/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp'
rm -f /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/libs32/armeabi-v7a/* /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/libs32/x86/*
rm -f /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/libs32/armeabi-v7a/gdbserver /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/libs32/x86/gdbserver
rm -f /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/libs32/armeabi-v7a/gdb.setup /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/libs32/x86/gdb.setup
[armeabi-v7a] Compile thumb  : sqlcipher <= sqlite3.c
rm -f /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/obj/local/armeabi-v7a/objs/sqlcipher/sqlite3.o
/home/jiong/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -MMD -MP -MF /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/obj/local/armeabi-v7a/objs/sqlcipher/sqlite3.o.d -target armv7-none-linux-androideabi16 -fdata-sections -ffunction-sections -fstack-protector-strong -funwind-tables -no-canonical-prefixes  --sysroot /home/jiong/android-ndk-r20b/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -Wno-invalid-command-line-argument -Wno-unused-command-line-argument  -fno-addrsig -fpic -march=armv7-a -mthumb -Oz -DNDEBUG  -I/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp -I/home/jiong/project/openssl/include -I/home/jiong/android-ndk-r20b/sources/cxx-stl/llvm-libc++/include -I/home/jiong/android-ndk-r20b/sources/cxx-stl/llvm-libc++abi/include -I/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp -D_FILE_OFFSET_BITS=32  -DANDROID -DLOG_NDEBUG -fstack-protector-all -nostdinc++ -Wa,--noexecstack -Wformat -Werror=format-security  -c  /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c -o /home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/obj/local/armeabi-v7a/objs/sqlcipher/sqlite3.o
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39210:42: error: use of undeclared identifier 'close'
  { "close",        (sqlite3_syscall_ptr)close,      0  },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39213:42: error: use of undeclared identifier 'access'
  { "access",       (sqlite3_syscall_ptr)access,     0  },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39216:42: error: use of undeclared identifier 'getcwd'
  { "getcwd",       (sqlite3_syscall_ptr)getcwd,     0  },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39236:42: error: use of undeclared identifier 'ftruncate'
  { "ftruncate",    (sqlite3_syscall_ptr)ftruncate,  0  },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39242:42: error: use of undeclared identifier 'read'
  { "read",         (sqlite3_syscall_ptr)read,       0  },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39259:42: error: use of undeclared identifier 'write'
  { "write",        (sqlite3_syscall_ptr)write,      0  },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39288:42: error: use of undeclared identifier 'unlink'; did you mean 'inline'?
  { "unlink",       (sqlite3_syscall_ptr)unlink,           0 },
                                         ^~~~~~
                                         inline
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39288:42: error: expected expression
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39297:42: error: use of undeclared identifier 'rmdir'
  { "rmdir",        (sqlite3_syscall_ptr)rmdir,           0 },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39301:42: error: use of undeclared identifier 'fchown'
  { "fchown",       (sqlite3_syscall_ptr)fchown,          0 },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39308:42: error: use of undeclared identifier 'geteuid'
  { "geteuid",      (sqlite3_syscall_ptr)geteuid,         0 },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39315:42: error: use of undeclared identifier 'mmap'
  { "mmap",         (sqlite3_syscall_ptr)mmap,            0 },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39322:42: error: use of undeclared identifier 'munmap'
  { "munmap",       (sqlite3_syscall_ptr)munmap,          0 },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39329:42: error: use of undeclared identifier 'mremap'
  { "mremap",       (sqlite3_syscall_ptr)mremap,          0 },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39343:42: error: use of undeclared identifier 'readlink'
  { "readlink",     (sqlite3_syscall_ptr)readlink,        0 },
                                         ^
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39404:22: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){
                     ^~~~~~~~~~
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39413:22: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
    for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){
                     ^~~~~~~~~~
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39440:20: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
  for(i=0; i<sizeof(aSyscall)/sizeof(aSyscall[0]); i++){
                   ^~~~~~~~~~
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:39457:16: error: invalid application of 'sizeof' to an incomplete type 'struct unix_syscall []'
    for(i=0; i<ArraySize(aSyscall)-1; i++){
               ^~~~~~~~~~~~~~~~~~~
/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp/sqlite3.c:14705:38: note: expanded from macro 'ArraySize'
#define ArraySize(X)    ((int)(sizeof(X)/sizeof(X[0])))
                                     ^~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[1]: Leaving directory `/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/cpp'
make[1]: *** [/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/src/main/obj/local/armeabi-v7a/objs/sqlcipher/sqlite3.o] Error 1

FAILURE: Build failed with an exception.

* Where:
Script '/home/jiong/project/android-database-sqlcipher/android-database-sqlcipher/native.gradle' line: 152

* What went wrong:
Execution failed for task ':android-database-sqlcipher:buildNative'.
> Process 'command '/home/jiong/android-ndk-r20b/ndk-build'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
2 actionable tasks: 2 executed
make: *** [Makefile:26:build-release] error 1


Can anyone help me,thx!

Hi @jiong103

You might try running make distclean, then try running the build again to see if the behavior is different.

@developernotes i found SQLCIPHER_CFLAGS= is empty ,and i change ${sqlcipherCFlags} to rootproject.ext.sqlcipherCFlags, i slove it , and build sucessfull !! thx for your reply!

Hi @jiong103

We are happy to hear you were able to resolve the build issue, thanks for the update!