How do I add SqlCipher to an Android.mk project?

I need to add SqlCipher to an existing Android app that uses an Android.mk file. It doesn’t use Eclipse or Android Studio.

The app is written entirely in Java (no JNI code). I was able to build and us SqlCipher in Eclipse but I need to make it build using an Android.mk file before I can submit my changes.

I copied the .jar and .so files to these sub diretories.

libs/google-play-services.jar
libs/sqlcipher.jar
libs/armeabi/libdatabase_sqlcipher.so
libs/armeabi/libsqlcipher_android.so
libs/armeabi/libstlport_shared.so
libs/armeabi-v7a/libdatabase_sqlcipher.so
libs/armeabi-v7a/libsqlcipher_android.so
libs/armeabi-v7a/libstlport_shared.so
libs/x86/libdatabase_sqlcipher.so
libs/x86/libsqlcipher_android.so
libs/x86/libstlport_shared.so

Below is how the Android.mk file looks currently.

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME := MyApplication
LOCAL_STATIC_JAVA_LIBRARIES := \
    sqlcipher \
    android-support-v4 \
    google-services

LOCAL_AAPT_FLAGS := --auto-add-overlay --extra-packages com.google.android.gms

LOCAL_PROGUARD_FLAG_FILES := proguard-project.txt

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/google_play_res/ $(LOCAL_PATH)/res

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := sqlcipher:libs/sqlcipher.jar \
                                        google-services:libs/google-play-services.jar

include $(BUILD_MULTI_PREBUILT)

I tried adding the below code to the Andorid.mk file but the .so files are not being added to the apk file.

include $(CLEAR_VARS)
LOCAL_MODULE := libdatabase_sqlcipher
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/armeabi-v7a/libdatabase_sqlcipher.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := libsqlcipher_android
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/armeabi-v7a/libsqlcipher_android.so
include $(PREBUILT_SHARED_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := libstlport_shared
LOCAL_SRC_FILES := $(LOCAL_PATH)/libs/armeabi-v7a/libstlport_shared.so
include $(PREBUILT_SHARED_LIBRARY)

Thank you.

I looks like I needed to set LOCAL_PREBUILT_JNI_LIBS.

However, I now get the following error.

01-06 00:54:15.564 E/art ( 8283): Failed to register native method net.sqlcipher.database.SQLiteDatabase.native_getDbLookaside()I in /system/app/MyApplication/MyApplication.apk
01-06 00:54:15.565 F/art ( 8283): art/runtime/jni_internal.cc:771] JNI FatalError called: RegisterNatives failed for ‘net/sqlcipher/database/SQLiteDatabase’; aborting…

The APK does contain assets/icudt46l.zip and the .so files are being copied to the device under
system/app/MyApplication/lib/arm

My 2nd problem was proguard. I had to add the following to proguard-project.txt.

-keep class net.sqlcipher.** {*;}
-dontskipnonpubliclibraryclassmembers