1
Firebusで初めてEventbusを使用しようとしています。FirebaseサービスでEventBus 3.0を使用している例外 - Android
次のエラーが「サブスクライバクラスjava.lang.Classであり、スーパークラスに@Subscribeアノテーションを持つパブリックメソッドがありません」というエラーが表示されます。
私は間違っていますか?
org.greenrobot.eventbus.EventBusException: Subscriber class java.lang.Class and its super classes have no public methods with the @Subscribe annotation
at org.greenrobot.eventbus.SubscriberMethodFinder.findSubscriberMethods(SubscriberMethodFinder.java:67)
at org.greenrobot.eventbus.EventBus.register(EventBus.java:136)
at net.techabout.medappointment.MyFirebaseMessagingService.onMessageReceived(MyFirebaseMessagingService.java:114)
at com.google.firebase.messaging.FirebaseMessagingService.zzo(Unknown Source)
at com.google.firebase.messaging.FirebaseMessagingService.zzn(Unknown Source)
at com.google.firebase.messaging.FirebaseMessagingService.zzm(Unknown Source)
at com.google.firebase.iid.zzb$2.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
私FirebaseMessageServiceは次のとおりです。
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.NoSubscriberEvent;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
.....
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Log.d(TAG, "Mensagem recebida!");
EventBus.getDefault().register(NoSubscriberEvent.class);
// Post the notification for an activity
EventBus.getDefault().post(remoteMessage);
}
@Subscribe
public void onMessageEvent(NoSubscriberEvent deadEvent) {
// We're all done here
EventBus.getDefault().unregister(this);
}
@Override
public void onCreate() {
super.onCreate();
EventBus.getDefault().register(this);
}
@Override
public void onDestroy() {
EventBus.getDefault().unregister(this);
super.onDestroy();
}
}
// ProGuardの-ルール
-keepattributes *Annotation*
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}