java - Android EventBus app crashes in release mode due to no @Subcribe methods -
the app works in debug, not in release
process: com.rubenwardy.monzolytics, pid: 14943 java.lang.runtimeexception: unable start activity componentinfo{com.rubenwardy.monzolytics/com.rubenwardy.monzolytics.mainactivity}: org.greenrobot.eventbus.eventbusexception: subscriber class com.rubenwardy.monzolytics.mainactivity , super classes have no public methods @subscribe annotation @ android.app.activitythread.performlaunchactivity(activitythread.java:2344) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2404) @ android.app.activitythread.access$800(activitythread.java:145) @ android.app.activitythread$h.handlemessage(activitythread.java:1323) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5319) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1016) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:811) caused by: org.greenrobot.eventbus.eventbusexception: subscriber class com.rubenwardy.monzolytics.mainactivity , super classes have no public methods @subscribe annotation @ org.greenrobot.eventbus.subscribermethodfinder.findsubscribermethods(subscribermethodfinder.java:67) @ org.greenrobot.eventbus.eventbus.register(eventbus.java:136) @ com.rubenwardy.monzolytics.mainactivity.onstart(mainactivity.java:88) @ android.app.instrumentation.callactivityonstart(instrumentation.java:1220) @ android.app.activity.performstart(activity.java:5992) @ android.app.activitythread.performlaunchactivity(activitythread.java:2307) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2404) @ android.app.activitythread.access$800(activitythread.java:145) @ android.app.activitythread$h.handlemessage(activitythread.java:1323) @ android.os.handler.dispatchmessage(handler.java:102) @ android.os.looper.loop(looper.java:135) @ android.app.activitythread.main(activitythread.java:5319) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1016) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:811)
here's gradle file: https://gist.github.com/rubenwardy/b467d1efd79c671f9a932d98768ff656
here proguard file:
-keep class com.androidplot.** { *; } # platform calls class.forname on types not exist on android determine platform. -dontnote retrofit2.platform # platform used when running on robovm on ios. not used @ runtime. -dontnote retrofit2.platform$ios$mainthreadexecutor # platform used when running on java 8 vms. not used @ runtime. -dontwarn retrofit2.platform$java8 # retain generic type information use reflection converters , adapters. -keepattributes signature # retain declared checked exceptions use proxy instance. -keepattributes exceptions -keepattributes *annotation* -keepclassmembers class ** { @org.greenrobot.eventbus.subscribe <methods>; } -keep enum org.greenrobot.eventbus.threadmode { *; } -keepclassmembers class com.rubenwardy.** { *; }
the error still occurs if replace proguard this:
-dontoptimize -dontshrink -dontusemixedcaseclassnames -dontskipnonpubliclibraryclasses -dontpreverify -verbose
i have @subscribe functions in mainactivity:
@subscribe protected void onperiodchange(final events.periodchangerequestedevent e) { log.e("mact", "period " + e.from.tostring() + " " + e.to.tostring()); filter = new transactionfilter() { @override public boolean isallowed(transaction transaction) { return transaction.created.gettime() > e.from.gettime() && transaction.created.gettime() < e.to.gettime(); } }; filtertransactions(); }
i have, ofc, googled - can't find results. please ask if need more information.
turns out @subscribe methods need public.
@subscribe public void onperiodchange(final events.periodchangerequestedevent e) { log.e("mact", "period " + e.from.tostring() + " " + e.to.tostring()); filter = new transactionfilter() { @override public boolean isallowed(transaction transaction) { return transaction.created.gettime() > e.from.gettime() && transaction.created.gettime() < e.to.gettime(); } }; filtertransactions(); }
Comments
Post a Comment