You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 30, 2019. It is now read-only.
Android apps that safely use new API classes as parameters in a method will still crash due to the following line in AnnotatedMethodHandler:
for (Method method : listenerClass.getDeclaredMethods())
An example set of methods:
@TargetApi(19)
private void doANewThingIfPossible() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
CaptioningManager captioningManager = (CaptioningManager) getActivity().getSystemService(Context.CAPTIONING_SERVICE);
doANewThingWithCaptioning(captioningManager);
}
@TargetApi(19)
private void doANewThingWithCaptioning(CaptioningManager mgr) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// Do something with captioning
}
}
A class with these methods is safe to run on an older device without Otto, but attempting to register this class to an Otto Bus will cause the class to crash with a java.lang.NoClassDefFoundError: android/view/accessibility/CaptioningManager upon registration.
There are definitely work-arounds and good coding practices that will prevent this, like inlining or moving doANewThingWithCaptioning to a new class, but wanted to bring it up as adding Otto to a pre-existing class can cause this to crop up.
The text was updated successfully, but these errors were encountered:
This is a symptom of older versions of Dalvik doing reflection in bulk. It's not specific to Otto but any reflection-based operation. Something as seemingly innocuous as specifying onClick bindings in XML will trigger this too. See:http://corner.squareup.com/2012/08/getting-to-the-bottom.html
I don't think there's much for us to do here. It's not a problem on modern runtimes and it's doubtful we'll ever do a code-gen version.
Cool, thanks for the link to the reading. Much appreciated. I wasn't positive there would be anything you could do short of returning to getMethods and giving up on the private-method-fast-fail, but wanted to note it.
Android apps that safely use new API classes as parameters in a method will still crash due to the following line in AnnotatedMethodHandler:
An example set of methods:
A class with these methods is safe to run on an older device without Otto, but attempting to register this class to an Otto Bus will cause the class to crash with a java.lang.NoClassDefFoundError: android/view/accessibility/CaptioningManager upon registration.
There are definitely work-arounds and good coding practices that will prevent this, like inlining or moving doANewThingWithCaptioning to a new class, but wanted to bring it up as adding Otto to a pre-existing class can cause this to crop up.
The text was updated successfully, but these errors were encountered: