Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException: Didn't find class "android.os.PersistableBundle" Otto Android 5.0

I have a strange issue. I have an app which I deployed on an Android 4.4 device and use Otto library. I deployed the app on an Android 5.0 device. It still works. I retried on the 4.4 and the app won't launched.

Apparently, it tries to use PersistableBundle.class which a API 21 class. Here my log :

    Caused by: java.lang.ClassNotFoundException: Didn't find class "android.os.PersistableBundle" on path: DexPathList[[zip file "/data/app/fr.myapp.apk"],nativeLibraryDirectories=[/data/app-lib/fr.myapp, /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.getDeclaredMethods(Class.java:656)
            at com.squareup.otto.AnnotatedHandlerFinder.loadAnnotatedMethods(AnnotatedHandlerFinder.java:52)
            at com.squareup.otto.AnnotatedHandlerFinder.findAllProducers(AnnotatedHandlerFinder.java:126)
            at com.squareup.otto.HandlerFinder$1.findAllProducers(HandlerFinder.java:33)
            at com.squareup.otto.Bus.register(Bus.java:191)
like image 761
Cocorico Avatar asked Mar 04 '15 15:03

Cocorico


1 Answers

I find the "solution". Just remove this function from your activity :

@Override
public void onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState) {
    super.onSaveInstanceState(outState, outPersistentState);
}
like image 127
Cocorico Avatar answered Oct 01 '22 15:10

Cocorico