Crashing when running SQL Cipher on Nexus 9


#1

My app is crashing when I debug my app on a Nexus 9 tablet with the following error. Crash happening on my loadLibs call. Any insight or help? This is a big problem for me.

SQLCipher 3.3.0 - Android 5.0.2 - Nexus 9

06-29 09:01:25.621: E/AndroidRuntime(3279): FATAL EXCEPTION: main
06-29 09:01:25.621: E/AndroidRuntime(3279): Process: com.tcoyle.testapp, PID: 3279
06-29 09:01:25.621: E/AndroidRuntime(3279): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.tcoyle.testapp-1/base.apk”],nativeLibraryDirectories=[/data/app/com.tcoyle.testapp-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn’t find "libstlport_shared.so"
06-29 09:01:25.621: E/AndroidRuntime(3279): at java.lang.Runtime.loadLibrary(Runtime.java:366)
06-29 09:01:25.621: E/AndroidRuntime(3279): at java.lang.System.loadLibrary(System.java:989)
06-29 09:01:25.621: E/AndroidRuntime(3279): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:142)
06-29 09:01:25.621: E/AndroidRuntime(3279): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:137)
06-29 09:01:25.621: E/AndroidRuntime(3279): at com.tcoyle.testapp.LoginActivity.InitializeSQLCipher(LoginActivity.java:109)
06-29 09:01:25.621: E/AndroidRuntime(3279): at com.tcoyle.testapp.LoginActivity.onCreate(LoginActivity.java:105)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.app.Activity.performCreate(Activity.java:5933)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.app.ActivityThread.access$800(ActivityThread.java:144)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.os.Handler.dispatchMessage(Handler.java:102)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.os.Looper.loop(Looper.java:135)
06-29 09:01:25.621: E/AndroidRuntime(3279): at android.app.ActivityThread.main(ActivityThread.java:5221)
06-29 09:01:25.621: E/AndroidRuntime(3279): at java.lang.reflect.Method.invoke(Native Method)
06-29 09:01:25.621: E/AndroidRuntime(3279): at java.lang.reflect.Method.invoke(Method.java:372)
06-29 09:01:25.621: E/AndroidRuntime(3279): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
06-29 09:01:25.621: E/AndroidRuntime(3279): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)


#2

Hello @tcoyle

Did you copy all native .so libraries to the libs folder within specific platform subfolders? An example can be found in the SQLCipher for Android tutorial here.


#3

Yes I did. here is a screenshot of my libs folder. I re-did this step several times to no avail.

screenshot of libs folder


#4

Your app attempts to load arm64 libraries, but SQLCipher for Android does not currently support any 64-bit architectures. There is an open pull request to support SQLCipher for Android on certain 64-bit architectures here: https://github.com/sqlcipher/android-database-sqlcipher/pull/151


#5

so it is not possible to run an app with SQL Cipher support on a Nexus 9 (or other 64 bit android device) with the current release as is?


#6

Hello @tcoyle,

SQLCipher for Android in the standard distribution runs fine on a Nexus 9 device. What IDE are you using to build your application?


#7

Android Studio 1.2.2 - Also if its worth it, up until I got the Nexus 9 device, it was working fine with the Nexus 9 emulator.


#8

So it appears the inclusion of the PSPDFKit PDF framework causes this error with SQLCipher. I have no idea how to go about preventing this from happening. There is no errors regarding the PDF framework, but as soon as I included it I get the linker error with SQLCipher.

Any suggestions, or questions I should pose to PSPDFKit support? Thanks.


#9

@tcoyle can you try adding one change at a time from your working project
until you see exactly which change causes the problem?


#10

Hi @tcoyle

Since you mentioned that you are using Android Studio, it is important to note that the native library structure is slightly different. Could you compare what you have with this tutorial? It may be worth reaching out to the PSPDFKit group to see if they can share any specifics about their dependencies. I would be curious as to their response. When you integrate both SQLCipher for Android and PSPDFKit, which library is initialized first when you receive the runtime exception?


#11

I followed your blog post about integrating with Android Studio. And it definitely works without PSPDFKit.

I tried reversing the order in which they are included, and initialized, and regardless it always crashes on the loadLibs() call. I will reach out to there support and see what they say.


#12

Hello @brodybits and @developernotes and @tcoyle

my app is crashing when I debug my app on a A-Lenovo A-7000-a tablet with the following error. Crash happening on my loadLibs call. Any insight or help? This is a big problem for me.

SQLCipher 3.3.0 - Android 5.0 - Lenovo A-7000-a

Eclipse juno - IDE is using to build my application.

please give me solution fast and fast…

here i attach my project structure :

07-10 11:28:32.040: E/libEGL(25870): cache file failed CRC check
07-10 11:28:34.097: E/AndroidRuntime(25870): FATAL EXCEPTION: main
07-10 11:28:34.097: E/AndroidRuntime(25870): Process: com.esense.topscorer, PID: 25870
07-10 11:28:34.097: E/AndroidRuntime(25870): java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.esense.topscorer-2/base.apk”],nativeLibraryDirectories=[/data/app/com.esense.topscorer-2/lib/arm64, /vendor/lib64, /system/lib64]]] couldn’t find "libstlport_shared.so"
07-10 11:28:34.097: E/AndroidRuntime(25870): at java.lang.Runtime.loadLibrary(Runtime.java:366)
07-10 11:28:34.097: E/AndroidRuntime(25870): at java.lang.System.loadLibrary(System.java:989)
07-10 11:28:34.097: E/AndroidRuntime(25870): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:118)
07-10 11:28:34.097: E/AndroidRuntime(25870): at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:113)
07-10 11:28:34.097: E/AndroidRuntime(25870): at com.esense.topscorer.scratchcard.DataBaseHelper.(DataBaseHelper.java:39)
07-10 11:28:34.097: E/AndroidRuntime(25870): at com.esense.topscorer.scratchcard.DataInitialization.getInternalData(DataInitialization.java:19)
07-10 11:28:34.097: E/AndroidRuntime(25870): at com.esense.topscorer.scratchcard.DataInitialization.setInternalData(DataInitialization.java:34)
07-10 11:28:34.097: E/AndroidRuntime(25870): at com.esense.topscorer.scratchcard.BaseActivity.setConnection(BaseActivity.java:95)
07-10 11:28:34.097: E/AndroidRuntime(25870): at com.esense.topscorer.scratchcard.LoginActivity.onCreate(LoginActivity.java:54)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.app.Activity.performCreate(Activity.java:6005)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2446)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2555)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.app.ActivityThread.access$800(ActivityThread.java:176)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1437)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.os.Handler.dispatchMessage(Handler.java:111)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.os.Looper.loop(Looper.java:194)
07-10 11:28:34.097: E/AndroidRuntime(25870): at android.app.ActivityThread.main(ActivityThread.java:5576)
07-10 11:28:34.097: E/AndroidRuntime(25870): at java.lang.reflect.Method.invoke(Native Method)
07-10 11:28:34.097: E/AndroidRuntime(25870): at java.lang.reflect.Method.invoke(Method.java:372)
07-10 11:28:34.097: E/AndroidRuntime(25870): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
07-10 11:28:34.097: E/AndroidRuntime(25870): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)


#13

If you look at the error message carefully, you can see that it is
searching for the native library a lib64 subdirectory. But sqlcipher for
Android does not have 64-bit version of native libraries.


#14

Hello @brodybits,

Thank you so much for kindly replay.

so it is not possible to run an myapp with SQL Cipher support on a Lenovo a-7000a (or other 64 bit android device) with the current release as is?


#15

so it is not possible to run an myapp with SQL Cipher support on a Lenovo
a-7000a (or other 64 bit android device) with the current release as is?

Personally I would not expect SQLCipher to work on 64-bit systems. But
there is already a pull request with some changes to build SQLCipher for
Android with 64-bit support here:
https://github.com/sqlcipher/android-database-sqlcipher/pull/151

You would have to build it from source, unless you can find a third-party
build.


#16

SQLCipher is now running perfectly fine on my 64bit Nexus 9.

The problem was that the PSPDFKit framework .aar include had .so include for arm64-v8a - causing the device to exclusively look for arm64-v8a libraries.

I removed the arm64-v8a from the PSPDFKit .aar file, and recompiled and the app and SQLCipher current release run fine.

Perhaps you are experiencing a similar issue chetan1011? Make sure no other frameworks you are including are running 64 bit libraries, as this will force SQLCipher to look for one which it does not currently have.


#17

SQLCipher is now running perfectly fine on my 64bit Nexus 9.

The problem was that the PSPDFKit framework .aar include had .so include
for arm64-v8a - causing the device to exclusively look for arm64-v8a
libraries.

I removed the arm64-v8a from the PSPDFKit .aar file, and recompiled and
the app and SQLCipher current release run fine.

Thanks tcoyle, I just filed
https://github.com/sqlcipher/android-database-sqlcipher/issues/185 to get
this documented.


#18

FYI the 64-bit version for Android is waiting for the OpenSSL project to accept the changes in https://github.com/openssl/openssl/pull/251. I just filed https://github.com/openssl/openssl/issues/333 to ask when they can look at the changes.