Android App (While integrating 32 bit and 64 bit) getting crashed due to sqlcipher.so

Hi

I have been working on one of android app which uses many native library including sqlcipher.so , so far i was working 32 bit app with 32 bit library .but as per client request we have created 64 bit version of our app  then started integrating 32 bit and 64 bit but while integrated i am getting below error : 

12-04 18:47:49.742 17475-17475/com.reference.ui E/art: Failed to register native method net.sqlcipher.database.SQLiteQuery.native_fill_window(Lnet/sqlcipher/CursorWindow;IIII)I in /data/app/com.reference.ui-1/split_lib_dependencies_apk.apk
12-04 18:47:49.743 17475-17475/com.reference.ui E/art: ----- class ‘Lnet/sqlcipher/database/SQLiteQuery;’ cl=0x12cd97c0 -----
** objectSize=292 (132 from super)**
** access=0x0008.0001**
** super=‘java.lang.Class<net.sqlcipher.database.SQLiteProgram>’ (cl=0x12cd97c0)**
** vtable (10 entries, 19 in super):**
** 0: void net.sqlcipher.database.SQLiteQuery.bindArguments(java.lang.Object)**
** 1: void net.sqlcipher.database.SQLiteQuery.bindDouble(int, double)**
** 2: void net.sqlcipher.database.SQLiteQuery.bindLong(int, long)**
** 3: void net.sqlcipher.database.SQLiteQuery.bindNull(int)**
** 4: void net.sqlcipher.database.SQLiteQuery.bindString(int, java.lang.String)**
** 5: int net.sqlcipher.database.SQLiteQuery.columnCountLocked()**
** 6: java.lang.String net.sqlcipher.database.SQLiteQuery.columnNameLocked(int)**
** 7: int net.sqlcipher.database.SQLiteQuery.fillWindow(net.sqlcipher.CursorWindow, int, int)**
** 8: void net.sqlcipher.database.SQLiteQuery.requery()**
** 9: java.lang.String net.sqlcipher.database.SQLiteQuery.toString()**
** direct methods (4 entries):**
** 0: void net.sqlcipher.database.SQLiteQuery.(net.sqlcipher.database.SQLiteDatabase, java.lang.String, int, java.lang.Object)**
** 1: void net.sqlcipher.database.SQLiteQuery.(net.sqlcipher.database.SQLiteDatabase, java.lang.String, int, java.lang.String)**
** 2: int net.sqlcipher.database.SQLiteQuery.native_column_count()**
** 3: java.lang.String net.sqlcipher.database.SQLiteQuery.native_column_name(int)**
** static fields (1 entries):**
** 0: java.lang.String net.sqlcipher.database.SQLiteQuery.TAG**
** instance fields (3 entries):**
** 0: java.lang.String net.sqlcipher.database.SQLiteQuery.mBindArgs**
** 1: java.lang.Object net.sqlcipher.database.SQLiteQuery.mObjectBindArgs**
** 2: int net.sqlcipher.database.SQLiteQuery.mOffsetIndex**

Testing my app on : Nexus 6 - 32 bit device with Marshmallow - 7.1.1

Your help would be benificiary Please revert me back as soon as possible.

Thanks,
Nandkishor Bhalerao

Hi @NandAli

I have a few follow-up questions to help understand the situation a bit better:

  • What version of SQLCipher for Android are you using?
  • Are you using the AAR package of SQLCipher for Android?
  • Are you using ProGuard to build your application?
1 Like

Hi @developernotes

Thank you so much for your quick response .

I will brief you some background :

  1. Earlier we were having 32 bit app with compiled sqlcipher.jar in libs folder with verison (v3.5.7-2-g188ecd7) and no aar package

  2. Then one of our onsite Engineer created 64 bit version of same application by doing some changes in 32 bit code like he added aar package with version ( compile ‘net.zetetic:android-database-sqlcipher:3.5.9@aar’) – here he has kept everything only 64 bit like .so and ABI’s

  3. Now it’s my job : i am started integrating 32 bit and 64 bit together by adding 32 bit related changes in to his created 64 bit application . In integrated code i am using 32 bit sqlcipher.so from 32 bit project and 64 bit sqlcipher.so which is already there in 64 bit project

  4. I have added all respective ABI changes ( such as APP_ABI:=armeabi-v7a arm64-v8a) in respective .mk files to make it integrated code but while launching application app getting crashed.

  5. In 64 bit code he has added net.sqlcipher source package in src/main/java with aar in build.gradle (he also kept uncompiled sqlcipher.jar in libs ) but in 32 bit code there were no net.sqlcipher package in src/main/java , there was only compiled sqcipher.jar in libs folder

  6. We are not using progaurd ,we have below code in build.gardle for progaurd :

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(‘proguard-android.txt’), ‘proguard-rules.txt’
}
}

Please have a look at folder structure of application:

Please let me know if needed more inputs

*Note – > Individual 32 bit and 64 bit application working fine , issue is happening only in integrated code while running on 32 bit device (Integrated code working fine for 64 bit device)

This appears as if you are using ProGuard with your release build. Would you try disabling that to see if it makes a difference?

Also, according to your screenshot, you are bundling individual libsqlcipher.so files. If you are referencing the AAR package, you would not need to do this as it will contain both 32 and 64-bit native libraries along with the necessary Java library. Can you remove your local inclusion of the .so and .jar files?

Hi @developernotes

Thanks for quick reply …:grinning:

  1. I think making minifyEnabled false will disable progaurd (If not then what is a way to make it disable)

  2. Actually i am new to this project so i will figure out why we need libsqlciper.so files at various location or can’t we just go with only AAR package

Regarding AAR package :

  1. Earlier in 32 bit App we were not using AAR package , we had only sqlcipher.jar in libs and libsqlcipher.so at respective path’s

  2. Could clarify what is the difference between only using sqlcipher.jar and AAR package

  3. As you said if we are using AAR then we don’t need to use libsqlcipher.so – I will check this out

  4. Any other alternative apart from AAR package inclusion

Hi @NandAli

Yes, good point, I think you are fine there.

This is the default packaging option now for SQLCipher for Android, which makes for easier upgrades/packaging. If you still have both the individual native libraries/jar and the AAR reference it may likely be causing the problem you are experiencing.

Hi @developernotes

  • Our App has native code dependency so first we build native code and put generated libraries (.so’s ) in App project

  • Our native code also has dependency over sqlcipher hence they might kept individual sqlcipher.so files at various path so that native code could reference it .

  • As per your guidance i had removed all libsqlcipher.so from all respective path but while building native code it’s getting failed

  • As you said if we put AAR package we don’t need to use any extra sqlcipher.so individually , hence could you please guide how to use AAR in order to resolve this dependency from native code

  • currently we are referring .so from Android.mk of native code as below :

      **include $(CLEAR_VARS)**
      **LOCAL_SRC_FILES := ../prebuilt/$(TARGET_ARCH_ABI)/libsqlcipher.so**
      **LOCAL_MODULE := sdk_dcc_sqlcrypt_prebuilt**
      **include $(PREBUILT_SHARED_LIBRARY)** 
    
    • Please give me way how to refer AAR in order to utilize it’s .so

Note : As our inidvidual 64 bit app working fine because they are using AAR as well as they have put .so to respective path in order to referred by native code (here our developer hasn’t put aar in app/lib also - as it is mentioned on zenetic site that there should aar inside app/lib )

So I am not sure how to utilize sqlcipher@aar , as our app having customized use of sqlcipher.so

Hello @NandAli

Unfortunately, due to the varying complexity of situations like this we do not provide public support for custom integration scenarios. If your organization is using SQLCipher in a commercial capacity, please feel free to reach out privately via support@zetetic.net to discuss advanced support agreements.