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
In Android, android.webkit.JavascriptInterface annotation exists on API Level 17 or later and its retention policy is runtime.
packageandroid.webkit;
importjava.lang.annotation.ElementType;
importjava.lang.annotation.Retention;
importjava.lang.annotation.RetentionPolicy;
importjava.lang.annotation.Target;
/** * Annotation that allows exposing methods to JavaScript. Starting from API level * {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} and above, only methods explicitly * marked with this annotation are available to the Javascript code. See * {@link android.webkit.WebView#addJavascriptInterface} for more information about it. * */@SuppressWarnings("javadoc")
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface JavascriptInterface {
}
So, calling Method.getAnnotation to method having this annotation in SubscriberMethodFinder occurs NoClsssDefFoundError if it runs under low API level(<17) device.
java.lang.NoClassDefFoundError: android/webkit/JavascriptInterface
at java.lang.reflect.Method.getAnnotation(Native Method)
at java.lang.reflect.Method.getAnnotation(Method.java:275)
at org.greenrobot.eventbus.SubscriberMethodFinder.findUsingReflectionInSingleClass(SubscriberMethodFinder.java:165)
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)
...
For example, if I make subscriber like following code and try registering it, EventBus will throws NoClassDefFoundError under low API level(<17) device.
@greenrobot-team I meet the same question with it.
I try to use subscriber index by android-apt method.And generate MyEventBusIndex.class success.But it is not useful!
The same error is still exist.That is mean it also use reflection?
In addition,Should I use @Subcriber instead of @subscribe?But I not found @subscriber in the project.
In Android, android.webkit.JavascriptInterface annotation exists on API Level 17 or later and its retention policy is runtime.
So, calling Method.getAnnotation to method having this annotation in SubscriberMethodFinder occurs NoClsssDefFoundError if it runs under low API level(<17) device.
For example, if I make subscriber like following code and try registering it, EventBus will throws NoClassDefFoundError under low API level(<17) device.
Thank you.
The text was updated successfully, but these errors were encountered: