
我正在尝试使用Greenrobot的Eventbus在Android应用程序中设置一个简单的订户,但是却遇到了gradle构建错误.我在下面显示了我的代码.
活动班
public final class OffersProcessedEvent {}基本片段
public class BaseFragment extends Fragment { private boolean registered; @OverrIDe public voID onVIEwCreated(VIEw vIEw, @Nullable Bundle savedInstanceState) { super.onVIEwCreated(vIEw, savedInstanceState); EventBus.getDefault().register(this); registered = true; } @OverrIDe public voID onResume() { super.onResume(); if (!registered) { EventBus.getDefault().register(this); registered = true; }} @OverrIDe public voID onPause() { super.onPause(); EventBus.getDefault().unregister(this); registered = false; } public AppCompatActivity getAppCompatActivity() { return (AppCompatActivity) getActivity(); }}活动发布
EventBus.getDefault().post(new OffersProcessedEvent());订阅代码
@Subscribe public voID onMessageEvent(OffersProcessedEvent event){ *do whatever* }以下是我的错误
构建Gradle错误
Error:No option eventBusIndex passed to annotation processor
Error:Execution Failed for task ‘:app:compileDeBUGJavaWithJavac’.
Compilation Failed; see the compiler error output for details.
Gradle依赖
dependencIEs { compile filetree(include: ['*.jar'], dir: 'libs') androIDTestCompile('com.androID.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.androID.support', module: 'support-annotations' }) compile 'com.androID.support:appcompat-v7:26.+' compile 'com.androID.support:design:26.+' compile 'com.androID.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile 'com.facebook.androID:facebook-android-sdk:4.5.0' compile 'com.jakewharton:butterknife:8.6.0' compile 'com.jakewharton:butterknife-compiler:8.6.0' compile 'com.jakewharton:butterknife:8.7.0' compile 'com.jakewharton:butterknife-compiler:8.7.0' compile 'com.github.bumptech.glIDe:glIDe:3.5.2' compile 'com.androID.support:cardvIEw-v7:26.0.0-Alpha1' compile 'com.Google.code.gson:gson:2.8.1' compile 'org.greenrobot:eventbus:3.0.0' compile 'org.greenrobot:eventbus-annotation-processor:3.0.1'}解决方法:
apply plugin: 'kotlin-kapt' // ensure kapt plugin is applIEddependencIEs { implementation 'org.greenrobot:eventbus:3.1.1' kapt 'org.greenrobot:eventbus-annotation-processor:3.1.1'}kapt { arguments { arg('eventBusIndex', 'com.example.myapp.MyEventBusIndex') }} 总结 以上是内存溢出为你收集整理的Greenrobot Android Eventbus-没有选项eventbusindex传递给注释处理器全部内容,希望文章能够帮你解决Greenrobot Android Eventbus-没有选项eventbusindex传递给注释处理器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)