gpt4 book ai didi

android - Greenrobot Android Eventbus - 没有选项 eventbusindex 传递给注释处理器

转载 作者:太空宇宙 更新时间:2023-11-03 13:44:30 26 4
gpt4 key购买 nike

我正在尝试使用 Greenrobot 的 Eventbus 在我的 Android 应用程序中设置一个简单的订阅者,但我遇到了 gradle 构建错误。我在下面显示了我的代码。

事件类

public final class OffersProcessedEvent {}

基础 fragment

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();
}
}

Activity 帖子'

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 applied

dependencies {
implementation 'org.greenrobot:eventbus:3.1.1'
kapt 'org.greenrobot:eventbus-annotation-processor:3.1.1'
}

kapt {
arguments {
arg('eventBusIndex', 'com.example.myapp.MyEventBusIndex')
}
}

关于android - Greenrobot Android Eventbus - 没有选项 eventbusindex 传递给注释处理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45452772/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com