android.app.Activity[] cannot be cast to java.lang.reflect.Method
arronvera opened this issue · 8 comments
when I register the eventbus,I met the exception “android.app.Activity[] cannot be cast to java.lang.reflect.Method”
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
any stacktrace of that exception?
java.lang.RuntimeException:Unable to start activity ComponentInfo{LauncherActivity}: java.lang.ClassCastException: android.content.Context[] cannot be cast to java.lang.reflect.Method
Caused by:
5 java.lang.ClassCastException:android.content.Context[] cannot be cast to java.lang.reflect.Method
6 java.lang.reflect.Method$1.compare(Method.java:67)
7 java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
8 java.util.TimSort.sort(TimSort.java:234)
9 java.util.Arrays.sort(Arrays.java:1492)
10 java.util.ArrayList.sort(ArrayList.java:1470)
11 java.util.Collections.sort(Collections.java:208)
12 libcore.util.CollectionUtils.removeDuplicates(CollectionUtils.java:86)
13 java.lang.Class.getMethods(Class.java:1493)
14 g.a.a.k.a(SubscriberMethodFinder.java:10)
15 g.a.a.c.a(EventBus.java:2)
16 g.a.a.c.c(EventBus.java:1)
17 LauncherActivity.onCreate(Native Method)
18 android.app.Activity.performCreate(Activity.java:8085)
19 android.app.Activity.performCreate(Activity.java:8073)
20 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
Caused by: java.lang.ClassCastException: android.app.Activity[] cannot be cast to java.lang.reflect.Method
at java.lang.reflect.Method$1.compare(Method.java:67)
at java.util.TimSort.binarySort(TimSort.java:296)
at java.util.TimSort.sort(TimSort.java:239)
at java.util.Arrays.sort(Arrays.java:1492)
at java.util.ArrayList.sort(ArrayList.java:1470)
at java.util.Collections.sort(Collections.java:208)
at libcore.util.CollectionUtils.removeDuplicates(CollectionUtils.java:86)
at java.lang.Class.getMethods(Class.java:1493)
at de.greenrobot.event.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:55)
at de.greenrobot.event.EventBus.register(EventBus.java:186)
at de.greenrobot.event.EventBus.register(EventBus.java:140)
Hm, thanks for reporting. But couldn't find any known issue.
Can you provide a small example to reproduce this?
@arronvera seems like you are using a very old version of EventBus.
Last version with de.greenrobot.event
package name was v2.4.0 (2014).
Nowadays the package name is org.greenrobot.eventbus
.
Please upgrade to v3+.
Thanks for spotting that! Closing this issue anyhow, no response for a long time.