Couldn't load realm-jni from loader

Couldn't load realm-jni from loader dalvik.system.PathClassLoader[DexPathList[dexElements=[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.couchgram.privacycall-1.apk", zip file "/data/data/com.couchgram.privacycall/code_cache/secondary-dexes/com.couchgram.privacycall-1.apk.classes2.zip"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]]: findLibrary returned null to Couldn't load realm-jni from loader
at java.lang.Runtime.loadLibrary(Runtime.java:359)
at java.lang.System.loadLibrary(System.java:514)
at io.realm.internal.RealmCore.loadLibrary(RealmCore.java:117)
at io.realm.internal.SharedGroup.<clinit>(SharedGroup.java:43)
at io.realm.internal.SharedGroupManager.<init>(SharedGroupManager.java:45)
at io.realm.BaseRealm.<init>(BaseRealm.java:87)
at io.realm.Realm.<init>(Realm.java:151)
at io.realm.Realm.createAndValidate(Realm.java:277)
at io.realm.Realm.create(Realm.java:245)
at io.realm.Realm.getInstance(Realm.java:217)
at com.couchgram.privacycall.common.RealmHelper.getInstance(RealmHelper.java:24)
public class RealmHelper {
public static Realm getInstance(Context context){
Realm realm = null;
RealmConfiguration config = new RealmConfiguration.Builder(context)
.name("couchCallSticker")
.schemaVersion(0)
.migration(new Migration())
.build();
try {
realm = Realm.getInstance(config);
}catch (RealmMigrationNeededException e){
LogUtils.v("DEBUG99", "RealmMigrationNeededException : " + e.getMessage());
Realm.migrateRealm(config);
realm = Realm.getInstance(config);
}catch (Exception e){
LogUtils.v("DEBUG99", "Realm Exception : " + e.getMessage());
}
return realm;
}
}
Hi @chonamdoo
What build tools version do you use? If you use 1.4.0-beta, use 1.3.2 instead to resolve this.
See also: #1421 https://code.google.com/p/android/issues/detail?id=188237 https://plus.google.com/+XavierDucrohet/posts/brM78vhMXwj
@dalinaum i use classpath 'com.android.tools.build:gradle:1.3.0'
@chonamdoo Which version of Realm do you use?
Do you have any other dependencies that contain native code?
If you find Korean devices which are crashed, please let us know. I'll visit your office then.
Solved! For me the problem wasn't the com.android.tools.build:gradle:1.3.0 or 1.3.1, it was classpath 'com.google.gms:google-services:1.4.0-beta3' !
So my project gradle looks like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.1' classpath 'com.google.gms:google-services:1.3.0-beta1' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' } }
allprojects { repositories { jcenter() } }
Didn't have to change com.google.android.gms:play-services-plus. Mine is still at com.google.android.gms:play-services-plus:8.1.0
Furthermore, I'm having bunch of issues with com.google.gms:google-services:1.4.0-beta3 - every now and then i'll get this error:
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2 and the building and running of app is super slow.
But anyways, I digress. I solved my issue by replacing classpath 'com.google.gms:google-services:1.4.0-beta3'
with classpath 'com.google.gms:google-services:1.3.0-beta1'
Tested on both 4.4.2 and 5.0.2 (physical devices)
@chonamdoo uses 'com.android.tools.build:gradle:1.3.0'. So it is not relevant to 1.4.0-beta issue.
@yshrsmz reported classpath 'com.android.databinding:dataBinder:1.0-rc3 can cause this problem.
https://github.com/realm/realm-java/issues/1421#issuecomment-146577403
Do you use this classpath, @chonamdoo?
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url "http://dl.bintray.com/countly/maven" }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
}
}
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
def timestamp() {
def date = new Date()
def formattedDate = date.format('yyyyMMddHHmmss')
return formattedDate.substring(2, 8)
}
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
apply plugin: 'io.fabric'
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
project.archivesBaseName = "Couchgram"
project.ext.set("buildTimestamp", timestamp());
defaultConfig {
applicationId "com.couchgram.privacycall"
versionCode 70
versionName "2.2.7"
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled true
ndk {
moduleName "couchssl"
}
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
signingConfigs {
releaseWith {
storeFile file(keystore);
storePassword keystore_pass
keyAlias key_alias
keyPassword key_pass
}
}
buildTypes {
debug {
// debuggable true
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.releaseWith
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
// debuggable true
minifyEnabled true
shrinkResources true
signingConfig signingConfigs.releaseWith
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'AndroidManifest.xml'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
jumboMode true
incremental true
javaMaxHeapSize "4g"
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
def apkFile = output.outputFile
if (apkFile != null && apkFile.name.endsWith('.apk')) {
def newApkName = apkFile.name.replace("-" + variant.buildType.name, "")
newApkName = newApkName.replace(".apk",
"-v" + defaultConfig.versionName + "-" + defaultConfig.versionCode +
"-" + variant.buildType.name.toUpperCase() + ".apk")
output.outputFile = new File(apkFile.parent, newApkName)
}
}
}
}
dependencies {
compile project(':cropimg')
compile project(':actionbar')
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':facebook')
compile project.ANDROID_BUILD_APPCOMPAT
compile project.ANDROID_BUILD_PLAY_SERVICES
compile project.ANDROID_BUILD_ANNOTATIONS
compile project.ANDROID_BUILD_RECYCLEVIEW
compile 'com.android.support:multidex:1.0.1'
compile 'com.googlecode.libphonenumber:libphonenumber:7.0.11'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'com.shehabic.droppy:Droppy:0.2.5.1@aar'
compile 'com.timehop.stickyheadersrecyclerview:library:0.4.2@aar'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.facebook.stetho:stetho:1.2.0'
compile 'com.facebook.stetho:stetho-okhttp:1.2.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'io.reactivex:rxandroid:1.0.1'
compile 'io.reactivex:rxjava:1.0.14'
compile 'com.github.lzyzsd:circleprogress:1.1.0@aar'
compile 'ly.count.android:sdk:15.08'
compile 'com.balysv.materialmenu:material-menu-toolbar:1.5.4'
compile 'com.github.pwittchen:networkevents:2.1.2'
compile 'com.squareup:otto:1.3.8'
compile 'jp.wasabeef:recyclerview-animators:1.3.0'
compile 'com.pubnub:pubnub-android:3.7.+'
compile 'net.danlew:android.joda:2.8.2'
compile 'io.realm:realm-android:0.83.0-SNAPSHOT'
compile 'com.github.lawloretienne:trestle:0.0.2'
compile group: project.KAKAO_SDK_GROUP, name: 'kakaolink', version: project.KAKAO_SDK_VERSION
compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'
compile 'org.bouncycastle:bcprov-jdk16:1.45'
compile 'com.romainpiel.shimmer:library:1.4.0@aar'
compile('com.crashlytics.sdk.android:crashlytics:2.+@aar') {
transitive = true;
}
}
I improve formatting, @chonamdoo :)
I have tested with Android Gradle plugin 1.5.0, databinder 1.0-rc4, google-services 1.4.0-beta3, and Realm 0.84.2. Calling Realm realm = Realm.getInstance(realmConfiguration); does work fine. I believe that the latest Android Gradle plugin solves the issue, and I close. If you experience the issue, don't hesitate to either reopen or create a new issue.
I know he doesn't use Android Gradle plugin 1.4.x and databinder. I requested upgrading his Realm version to 0.85 or above version. He will include this on his next release.
He updated his Realm version to 0.86 and still have this problem. I'll reopen this.
@dalinaum @chonamdoo Can you try to create a minimal app which can reproduce it on a physical device?
We have merged #1771 to use ReLinker to give the loading of .so files a second chance to work. You can try it out as a snapshot release.
With ReLinker merged to 0.88-SNAPSHOT i'll close this issue now. Please reopen if the problem persists.