Closed mrp14 closed 7 years ago
What was the older version?
It was 1.1.0.
I have a weird behavior : I just tried to downgrade to 1.1.0, and got the same error. It was working fine before, I don't get it....
Any clue about how to find the culprit ?
My first advice would be to disable Instant Run, then do a clean/rebuild.
I did it, same results. I also removed realm related dependencies (realm-stetho and realm android adapters). No success for the moment. And I'm still in 1.1.0.
What gradle version are you using?
Gradle 2.14.1, and Android plugin 2.2.0
I suspect that multidex does not put org.gradle.internal.logging.slf4j.*
classes into main dex.
Could you edit app/build.gradle
like:
android {
defaultConfig {
...
multiDexEnabled = true
multiDexKeepProguard file('multi-dex-keep.txt') // ADD THIS LINE
}
...
}
and put app/multi-dex-keep.txt
whose content is:
-keep public class org.gradle.internal.logging.slf4j.** {
*;
}
Does this solve the problem?
Please reopen if you have any updates.
We just encountered this issue as well. We have our own StaticLoggerBinder but it seems like Realm is trying to bring his own (Which I really think should not be the case!). Apparently the one from Realm is used and the project fails to find org.gradle.internal.logging.slf4j, most probably because proguard removed them as unused being that our StaticLoggerBinder is not using them.
I'm trying to find a way to exclude the realm-imported StaticLoggerBinder so that our can work, do you have suggestions?
@lucavitucci And the suggestion about DEX above didn't help you?
Same error even after applying your fix,
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext" on path: DexPathList[[zip file "/data/app/com.centralway.numbrs.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/com.centralway.numbrs.debug-1/lib/arm, /data/app/com.centralway.numbrs.debug-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
We verified and removing Realm makes the app run again.
Otherwise, in build/intermediates/classes we can see our StaticLoggerBinder while in build/intermediates/transforms/realmTransformer our class is already magically replaced with the StaticLoggerBinder from gradle.
Stacktrace:
01-30 16:14:43.223 14832-14832/com.vexdev.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.vexdev.myapplication, PID: 14832
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/gradle/internal/logging/slf4j/OutputEventListenerBackedLoggerContext;
at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:30)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:27)
at org.slf4j.impl.StaticLoggerBinder.getSingleton(StaticLoggerBinder.java:33)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at com.vexdev.myapplication.Main2Activity.<init>(Main2Activity.java:15)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.gradle.internal.logging.slf4j.OutputEventListenerBackedLoggerContext" on path: DexPathList[[zip file "/data/app/com.vexdev.myapplication-2/base.apk"],nativeLibraryDirectories=[/data/app/com.vexdev.myapplication-2/lib/arm64, /data/app/com.vexdev.myapplication-2/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:30)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:27)
at org.slf4j.impl.StaticLoggerBinder.getSingleton(StaticLoggerBinder.java:33)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at com.vexdev.myapplication.Main2Activity.<init>(Main2Activity.java:15)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2557)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Sample project:
I reproduced this bug with your sample project. It seems that there are some bugs in our transformer.
Fixed by #4127
@lucavitucci Thanks. Your sample project helps me a lot! Snapshot build will be deployed shortly.
Could you try it when you have a time? https://github.com/realm/realm-java/blob/master/README.md#using-snapshots (I already confirmed that your sample project worked as expected with my local build of Realm though.
@zaki50 Thank you for the fastest reaction time I've ever encounter after reporting a bug 👍 I just verified on our main project and can confirm that 2.4.0-SNAPSHOT is now working.
@lucavitucci @mrp14 Thank you for your confirmation.I'll close this.
This seems to be happening again with realm
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.10"
classpath "io.realm:realm-gradle-plugin:4.2.0"
@cmelchior @mlostekk can you provide the complete list of dependencies?
I've tried Kotlin things before and this didn't happen?
Hey @Zhuinden please see the issue https://github.com/realm/realm-java/issues/5641
When rolling back to the latest major version 3, then everything runs fine. Maybe the issue got introduced again like it already happened twice?
Hello,
I just updated realm from an older version to 2.0.1. From here, I'm unable to have my app working. It seems to be the same bug as #3018 and #3043 :
In debug mode, app builds fine but crashes at launch with this error :
In release mode, app does not build :
Here is my messy build.gradle :
Regards,