Skip to content

Crash on Android 6.0 emulator #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TomAtRB opened this issue Aug 20, 2015 · 36 comments
Closed

Crash on Android 6.0 emulator #190

TomAtRB opened this issue Aug 20, 2015 · 36 comments

Comments

@TomAtRB
Copy link

TomAtRB commented Aug 20, 2015

I am getting a crash on launch when trying to test on an Android 6.0 emulator

java.lang.UnsatisfiedLinkError: dlopen failed: ... lib/x86/libsqlcipher_android.so: has text relocations

Using:
sqlcipher-for-android-v3.3.1
Android emulator x86 API 23 (6.0)

@developernotes
Copy link
Member

Hello @TomAtRB

Are you certain you have integrated the library according to the documentation here? I was just able to run the SQLCipher for Android test suite on the x86 emulator for API 23 successfully.
screen shot 2015-08-21 at 4 42 51 pm

@TomAtRB
Copy link
Author

TomAtRB commented Aug 21, 2015

I am able to replicate the crash in the test suite by updating the "targetSdkVersion" and "compileSdkVersion" to "23"

/net.zetetic E/AndroidRuntime﹕ FATAL EXCEPTION: AsyncTask #1
    Process: net.zetetic, PID: 22424
    java.lang.RuntimeException: An error occurred while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:309)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
            at java.lang.Thread.run(Thread.java:818)
     Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/net.zetetic-1/lib/x86/libsqlcipher_android.so: has text relocations
            at java.lang.Runtime.loadLibrary(Runtime.java:372)
            at java.lang.System.loadLibrary(System.java:1076)
            at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:140)
            at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:135)
            at net.zetetic.tests.TestSuiteRunner.runSuite(TestSuiteRunner.java:36)
            at net.zetetic.tests.TestSuiteRunner.doInBackground(TestSuiteRunner.java:20)
            at net.zetetic.tests.TestSuiteRunner.doInBackground(TestSuiteRunner.java:12)
            at android.os.AsyncTask$2.call(AsyncTask.java:295)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
            at java.lang.Thread.run(Thread.java:818)

@developernotes
Copy link
Member

Hello @TomAtRB

I was able to reproduce this by adjusting the targetSdkVersion and compileSdkVersion. I will look into this. Thanks!

@ErnestG
Copy link

ErnestG commented Sep 8, 2015

@developernotes any chance it's because of

Android is moving away from OpenSSL to the BoringSSL library. If you’re using the Android NDK in your app, don't link against cryptographic libraries that are not a part of the NDK API, such as libcrypto.so and libssl.so. These libraries are not public APIs, and may change or break without notice across releases and devices. In addition, you may expose yourself to security vulnerabilities. Instead, modify your native code to call the Java cryptography APIs via JNI or to statically link against a cryptography library of your choice.

https://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client

@developernotes
Copy link
Member

Hi @ErnestG

It is unlikely due to the libcrypto dependency. We are actually building our own version of libcrypto and linking that directly into the library, so we are not dependency on any specific version of libcrypto being available on a given Android device.

@kmusham
Copy link

kmusham commented Sep 14, 2015

I am also getting the same error with the same environment.
Did you find any solution or workaround yet?

@developernotes
Copy link
Member

Hello @kmusham

We are looking into the issue, at the time being we recommend that you do not target API 23 until this issue is resolved.

@jdzuri
Copy link

jdzuri commented Sep 17, 2015

I have the same error too. I remain waiting for its solution. Thank you @developernotes for the info.

@developernotes
Copy link
Member

Hi @TomAtRB, @ErnestG, @kmusham,

I have just pushed up a fix in the master branch that addresses the text relocation crash reported above. Please take a look when you get the opportunity. Thanks!

@jdzuri
Copy link

jdzuri commented Sep 23, 2015

Hello @developernotes,

I've tested the library with the fix and work fine with the API 23 (emulator and hardware preview-3).

Thanks!

@developernotes
Copy link
Member

Hi @jdzuri

Thank you for reporting your success with the latest changes.

@powder366
Copy link

Where do I get the new jniLibs files (+ icudt46l.zip)? The last version here is from Jul 13 v3.3.1: https://github.com/sqlcipher/android-database-sqlcipher/releases
And here is also old https://www.zetetic.net/sqlcipher/open-source/ stuff. Seems I can't get hold of the binaries?

@developernotes
Copy link
Member

Hello @powder366

We have just released the latest version of SQLCipher for Android, more information can be found here.

@powder366
Copy link

Thanks worked great. It seems one don't need the ".so" files anymore?

@developernotes
Copy link
Member

@powder366 you still need them, the .so files are bundled with the .aar package.

@maniacs-engineerica
Copy link

Hi, I am trying to apply this fix, but I don't understand. Does this bug only occurs in emulator? I don't have a real device with API 23.

Anyway, which files do I have to update in my project to add this fix solution?
Thanks!

@developernotes
Copy link
Member

Hello @maniacs-engineerica

The issue was verified within the emulator when running with a target SDK set to 23. The specific commit that addressed the issue can be found here: 098ecdb.

@maniacs-engineerica
Copy link

Thank you for your help. I am not sure on how to include new libcrypto.a in my project, can you help me?
Thanks!

@developernotes
Copy link
Member

Hello @maniacs-engineerica

The static libraries are already built into the binary distribution, you can just reference the AAR package that is available through jcenter or Maven Central.

@maniacs-engineerica
Copy link

That's perfect. It works! Thank you.

@sagarkakad
Copy link

I m having Android App that uses SQL cipher 2.2.0 library to encrypt the db. After Android 6.0 upgrade we updated to SQL cipher 3.3.1 since previous library was giving problem on android 6.0. After the sql cipher upgrade the app started working on android 6.0 as well. But the problem is it is not able to read the already encrypted DB (encrypted using cipher 2.2.0).
It is giving following error
" sqlite returned: error code =26, msg=file is encrypted or is not a database:
CREATE TABLE android_metadata failed.
failed to setLocale() when constructing, closing the database.
create locale table failed.
old jar is

compile file('build/intermediates/rs/debug/lib.sqlcipher.jar')
i am using following jar

compile 'com.android.support:support-v4:23.0.0'
compile 'net.zetetic:android-database-sqlcipher:3.3.1-1@aar'

Is it that encryption algorithm has changed or am i doing some mistake.

Please help.

@TheNephilim88
Copy link

Did you migrate your db to new v3-format?
https://www.zetetic.net/sqlcipher/sqlcipher-api/#cipher_migrate

@developernotes
Copy link
Member

Hello @sagarkakad

@TheNephilim88 is correct, you will need to upgrade the database file to the new 3.x format using the PRAGMA cipher_migrate; command.

@sagarkakad
Copy link

how can i upgrade database file to new 3.x format using PRAGMA cipher_migrate;

I cannot use command i have to do it through android program. Currently i m using sqlcipher 3.3.1 version

please guide me...

@developernotes
Copy link
Member

Hello @sagarkakad

There is an example of the usage within the SQLCipher for Android test suite here.

@sagarkakad
Copy link

Thanks @developernotes & @TheNephilim88 .

I had to do few changes ,

  • Instead of using the sqlcipher.jar provided in test suite i added following line in gradle file
    ==> compile 'net.zetetik:android-database-sqlcipher:3.3.1-2@aar'
    before that it was giving error for net.sqlcipher.DatabaseErrorHandler
  • The above link downloads the .SO files as well. I ignored those file and added the ones provided in test suite.

After this updates My APP is working 👍 , but I am facing 2 problem

  1. The App speed has slowed (the latency has increased by 5 times) . Not sure why because at code level there is no change except for migration to 3.3.1 cipher and that happens only once on SQLException.
  2. APK size has increased. Not Sure but may be because of .SO file added for armeabi, armv7 & x86.

Please suggest me to sort out above problem. I am more concern about speed

Thanks Again!!! 👍

@developernotes
Copy link
Member

Hello @sagarkakad

Instead of using the sqlcipher.jar provided in test suite i added following line in gradle file
==> compile 'net.zetetik:android-database-sqlcipher:3.3.1-2@aar'

Just for clarification, the correct AAR reference name should be:

compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar'

The above link downloads the .SO files as well. I ignored those file and added the ones provided in test suite.

It is not recommended that you mix and match jars and .so files from different distributions. This behavior could certainly cause issues. Is there a reason you are opting to not use the binaries distributed in AAR package provided?

With regard to the performance impact of SQLCipher within your application, I would recommend reviewing the SQLCipher performance guidance we have posted here. The binary size of your application will increase due to the various components of SQLCipher.

@sagarkakad
Copy link

Hello @developernotes

Thanks for support

When i am using sqlcipher 2.2 my app responds very fast, their is no time delay. now i am replace only sqlcipher2.2 with sqlcipher 3.3.1 using
compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar'

because sqlcipher 2.2 it not supporting to Android 6.0 now my app with same code gets very slow.
i need to wait few seconds after every click then next operation perform.
how i overcome from this
plz guide me .......

Thanks

@developernotes
Copy link
Member

Hello @sagarkakad

Have you reviewed the SQLCipher performance guidance provided here? If not, I would recommend evaluating your application to identify specifically where the slowness is occurring and make the appropriate adjustments.

@hendrysetiadi89
Copy link

compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar'

give me error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 2

@hendrysetiadi89
Copy link

Ahh. nvm..
I solved it. It is because it has conflict with the old jar. I have to clean and rebuild project.

Thank you very much.
This is Great.

@developernotes
Copy link
Member

Hi @hendrysetiadi89

Thanks for getting back to us, we are glad to hear the issue has been resolved.

@zamesilyasa
Copy link

I steel have the issue on android 6.0 with 3.4.0 and 3.3.1 on x86 platform(genymotion).
I am not sure about real devices, I believe it will work, but not sure.

@McPo
Copy link

McPo commented May 23, 2016

@zamesilyasa double check that the so file that is being installed on the device is the same within the AAR, and that the older so, is not being re-installed. Use adb pull then run a checksum.

In my case Android Studio was aggressively caching the SO file. Had to wipe the genymotion VM, clean the build, delete build folder then searched and deleted all occurrences of libsqlcipher_android.so

It eventually worked.
You can double check that an so file has text relocations disabled by following this guide http://slowbutdeadly.blogspot.co.uk/2015/09/javalangunsatisfiedlinkerror-dlopen.html

@greyowly
Copy link

@developernotes is there anything different with so file ? I run my apps on marshmallow device and using compile 'net.zetetic:android-database-sqlcipher:3.3.1-2@aar', it's working just fine ( no so file in the project ). But when i run the project into < marshmallow, i got the error db file is not a database or encrypted file. But when i add so file into the project, there's no problem with it. But when i run into Marshmallow, it give me error java.lang.UnsatisfiedLinkError: dlopen failed: /data/app/com.grey.project/lib/arm/libstlport_shared.so: has text relocations

@developernotes
Copy link
Member

Hello @greyowly

The latest version of the library is currently 3.5.2, would you try that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests