Skip to content
This repository has been archived by the owner on Apr 30, 2019. It is now read-only.

java.lang.NoClassDefFoundError for android/os/PersistableBundle during registering activity on Bus #139

Open
Den-Rimus opened this issue Jan 16, 2015 · 11 comments

Comments

@Den-Rimus
Copy link

01-16 00:36:40.009  27061-27061/net.mobindustry.shopaholic E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: android/os/PersistableBundle
            at java.lang.Class.getDeclaredMethods(Native Method)
            at java.lang.Class.getDeclaredMethods(Class.java:703)
            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)

I've seen this issue. But I just don't get - we get this crash on all pre21 API devices with our app - during OttoBusProvider.getInstance().register(this); in onPause().
Looking at the number of forks and start I assume that lots of people and teams are using this library - how comes they don't get the crash?

Is there any possible workaround here?

P. S.: before we tried EventBus lib from greenrobot - same error, identical stack, only package name differs.

@Sivanga
Copy link

Sivanga commented Jan 18, 2015

Same thing for us.

@xsveda
Copy link

xsveda commented Feb 4, 2015

I don't think it has anythink to do with Otto.
android.os.PersistableBundle is a class introduced in Lollipop for a new mechanism of "resurecting" apps after i.e. system restart. See [Activity.onCreate(Bundle, PersistableBundle)](http://developer.android.com/reference/android/app/Activity.html#onCreate%28android.os.Bundle, android.os.PersistableBundle%29).
I saw this error comming from RoboGuice library when injecting an Activity, but unfortunately I did not find the proper cause yet...

@DrorFichman
Copy link

We had a (similar) issue when using Bus in a class which referenced 'Objects' type.
Resolved when we removed the use of this specific type.

@CorentinPacaud
Copy link

I have the same issue after deploy successfully on a Lollipop device and try to deploy on a 4.4.4 device.
When I try to re deploy on Android 5.0, it works.
Trying to set targetSDK to 19 doesn't work.
So, what can we do to correct this ?

@CorentinPacaud
Copy link

@danielgomezrico
Copy link

So How can I manage it?

@CorentinPacaud
Copy link

It's said in the Stackoverflow Topic.

@danielgomezrico
Copy link

But what If I need to use onSaveInstanceState ? so how can I manage the save on my actual activity state?

@CorentinPacaud
Copy link

Maybe you mean this function : Activity : protected void onSaveInstanceState (Bundle outState)
It's different than onSaveInstanceState(Bundle outState, PersistableBundle outPersistentState)

Otherwise, you need to check if your on API 21 and over or not.

@danielgomezrico
Copy link

Opa, yeah! thanks!!

@lkw103037
Copy link

I fix it! @CorentinPacaud @xsveda is right! change function to Activity.onCreate(Bundle) or onSaveInstanceState (Bundle outState) . it's work fine. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants