Java – after using subscriber index, greenrobot eventbus and classnotfoundexception still exist
I have a general "classnotfoundexception" issue eventbus with 4.4.2 device, which even has trouble in FAQ
I first carefully checked that I did not use any unused lifecycle methods, but did not use them. Then I updated to eventbus 3.0.0 and used the "subscriber index". However, the error still exists. I can still see in my stack trace that the builder is trying to use reflexivity (findusingreflectioninsingleclass):
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.os.PersistableBundle" on path: DexPathList[[zip file "/data/app/com.m360.android.debug-6.apk"],nativeLibraryDirectories=[/data/app-lib/com.m360.android.debug-6, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at java.lang.Class.getDeclaredMethods(Native Method)
at java.lang.Class.getPublicMethodsRecursive(Class.java:894)
at java.lang.Class.getmethods(Class.java:877)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(SubscriberMethodFinder.java:157)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingInfo(SubscriberMethodFinder.java:88)
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:64)
at org.greenrobot.eventbus.EventBus.register(EventBus.java:136)
at com.m360.android.activity.PlayerActivity.onStart(PlayerActivity.java:977)
at ...
During player activities:
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(QuestionFragment.EnableNextEvent event) {
/* ...... */
}
@Override
protected void onStart() {
super.onStart();
EventBus.builder().addIndex(new MyEventBusIndex()).build().register(this);
}
@Override
protected void onStop() {
super.onStop();
EventBus.getDefault().unregister(this);
}
Myeventbusindex is also available, so I guess my build file is good
If you find the problem, please let me know
resolvent:
I encountered the same error on galaxy S3 (Android 4.3). It occurred on Android with API level lower than 21. You directly referenced persistent bundle
"Eventbus 3 with subscriber index" doesn't help me (you). So I found a solution here
One more error / reason is here
Postscript event bus 3.0.0