Closed
Description
Receive crashes on production users:
Fatal Exception: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
at java.lang.reflect.Method.getAnnotation(Method.java)
at java.lang.reflect.Method.getAnnotation(Method.java:266)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(Unknown Source:165)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingInfo(Unknown Source:88)
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(Unknown Source:64)
at org.greenrobot.eventbus.EventBus.register(Unknown Source:136)
at com.*****.BaseActivity.onResume(Unknown Source:73)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1192)
at android.app.Activity.performResume(Activity.java:5364)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2924)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3042)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2337)
at android.app.ActivityThread.access$800(ActivityThread.java:184)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1280)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5281)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
at dalvik.system.NativeStart.main(NativeStart.java)
Code:
@Override
protected void onResume() {
super.onResume();
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this); //crash is here
}
}
Dexguard:
-keepattributes JavascriptInterface
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
Eventbus version - 3.0.0
For now have only 5 crashes, 3 users. Android: 4.1.2, 4.4.2. Devices: Sony Xperia GX, Kyocera TORQUE G01, Fujitsu F-01F
Activity
greenrobot-team commentedon Mar 14, 2017
java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation
indicates that the class (one of your classes that contains a@Subscribed
annotation) in question seems to be different in your final APK (specifically the dex file).This may be related to multi-dex or if you somehow included these classes twice as a dependency.
-ut
Andoctorey commentedon Mar 22, 2017
Thanks. Probably found problem. We rewrote EventBusBuilder and EventBus classes, added some logs. EventBusBuilder constructor is not public, se we put custom classes in
org.greenrobot.eventbus
package. Maybe it caused problem.greenrobot-team commentedon Mar 27, 2017
Alright, closing this then. -ut
BornLotus commentedon Jun 8, 2018
Now, I faced the same problem as above,can you tell me why and what I should do with it? thanks a lot
DeanKersting commentedon Apr 4, 2019
This is usually happened when call Eventbus.register(subscribe),subscribe Class is belonged to a different dex which is not THE dex Eventbus class belonged to!So you can add Eventbus ref(such as Eventbus.class.getName()) in your subscribe class to prevent it being marked as 'class_preverified' by Dalvik VM,ART VM don't have this problem),it will solve ur problem!
liuyan82 commentedon Oct 21, 2019
Thanks. Saved my day.
juanlabrador commentedon Jan 28, 2020
@liuyan82 please you can show me how fix that, please!
juanlabrador commentedon Feb 6, 2020
It happens when Dexguard is active, How I can add Eventbus ref in subscribe class?
soochun-deali commentedon Mar 14, 2020
same here with after applying dexguard
soochun-deali commentedon Mar 19, 2020
fix with below rule added
dexguard version : 8.6.06
eventbus version : 3.2.0
-keepnames class org.greenrobot.eventbus.**
-keep class org.greenrobot.eventbus.** { *; }