I created a very minimal application, just showing "Hello World".
The main activity makes a call to load the SQLCipher libraries.
package companydomain.myapplication;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import net.sqlcipher.database.SQLiteDatabase;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SQLiteDatabase.loadLibs(this); // loading the SQLCipher libraries
}
}
The build.gradle (module: app) is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
}
return void
}
dependencies {
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'net.zetetic:android-database-sqlcipher:3.5.4@aar'
}
This app works as intended.
However, when I add Crashlytics to the build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
}
return void
}
dependencies {
compile 'com.android.support:appcompat-v7:25.0.1'
compile 'net.zetetic:android-database-sqlcipher:3.5.4@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.5@aar') {
transitive = true;
}
}
crashlytics {
enableNdk true
androidNdkOut 'src/main/obj'
androidNdkLibsOut 'src/main/libs'
}
upon start the app crashes with an error "java.lang.UnsatisfiedLinkError ... couldn't find "libsqlcipher.so" - I don't even make a call to Crashlytics from my activity.
--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: companydomain.myapplication, PID: 2887
java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/companydomain.myapplication-2/base.apk"],nativeLibraryDirectories=[/data/app/companydomain.myapplication-2/lib/x86_64, /vendor/lib64, /system/lib64]]] couldn't find "libsqlcipher.so"
at java.lang.Runtime.loadLibrary(Runtime.java:366)
at java.lang.System.loadLibrary(System.java:989)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:196)
at net.sqlcipher.database.SQLiteDatabase.loadLibs(SQLiteDatabase.java:189)
at companydomain.myapplication.MainActivity.onCreate(MainActivity.java:21)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
This happens only for x86_64 and arm64_v8a ABIs. In the latter case the error list contains "arm64_v8a" instead of "x86_64"
Any idea what is wrong?
Thanks in advance,
Gerhard
Found the answer by myself.
SQLCipher obviously do not support 64-bit architecture.
So in the build.gradle I added an abiFilter-statement to exclude 64-bit architectures:
...
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
ndk {
abiFilters "armeabi", "armeabi-v7a", "x86", "mips"
}
}
return void
}
....
No crashes anymore!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With