Dagger2中发生android.app.Activity is bound multiple times:
来源:互联网 发布:linux yum 安装rpm 编辑:程序博客网 时间:2024/06/05 18:57
android.app.Activity is bound multiple times:
上面已经很明显说明了,这里绑定了两次了。
具体的代码如下。
AppComponent.java文件:
@Singleton@Component(modules = AppModule.class)public interface AppComponent { public Activity getActivity(); void inject(App app); void inject(BaseActivity baseActivity);}
ActivityComponent.java文件:
@PerActivity@Component(dependencies = AppComponent.class, modules = ActivityModule.class)public interface ActivityComponent { public Activity getActivity();}
ActivityModule.java文件
@Modulepublic class ActivityModule { private final Activity mActivity; public ActivityModule(Activity activity) { this.mActivity = activity; } @Provides @PerActivity public Activity provideActivity() { return this.mActivity; }}
AppModule.java文件
@Modulepublic class AppModule { private final Context mContext; public AppModule(Context context) { this.mContext = context; } @Provides @Singleton public Context provideAppContext() { return mContext.getApplicationContext(); } @Provides @Singleton public Activity provideActivity() { return null; }}
@Scope@Retention(RetentionPolicy.RUNTIME)public @interface PerActivity {}
这里从ActivityComponent.java文件开始分析:
@Component(dependencies = AppComponent.class, modules = ActivityModule.class)
文件中的:
public Activity getActivity();表明它需要从对应的dependencies或者modules中取得这里的Activity。
它们中都有相关的方法提供Activity的方法,所以导致出现了问题。
0 0
- Dagger2中发生android.app.Activity is bound multiple times:
- CCS error: symbol trace buf is defined multiple times
- Why is NSNotification its observer called multiple times
- Activity life times——Android
- Android Application class method onCreate being called multiple times
- sign apk multiple times
- The provider for invariant name 'System.Data.SqlClient' is specified multiple times in the applicati
- Bug:'xxActivity' is not assignable to 'android.app.Activity
- Use ResultSet repeated (multiple times)
- [Flex]itemEditEnd called multiple times
- Android中一个app启动另一个app的指定activity
- Android中一个app启动另一个app的指定activity
- Android中一个app启动另一个app的指定activity
- Android中一个app启动另一个app的指定activity
- Slow App Startup Times
- 用ccs编译文件后出现如下错误: error: symbol _USER10_ISR is defined multiple times: D:\CCStudio_v3.1\MyProjects\BL
- Android中使用Dagger2进行依赖注入
- android.view.View 中获取 android.app.Activity
- 阅读程序——4
- MySQL常用的SQL查询语句
- ios开发中如何隐藏各种bar
- 百度地图定位demo
- 复制一个文件夹的内容到另外一个文件夹,利用递归
- Dagger2中发生android.app.Activity is bound multiple times:
- UIGraphicsGetCurrentContext()的使用
- 第十五周C++范型程序补充阅读(2)
- LeetCode-70.Climbing Stairs
- UIButton设置高亮状态下的背景色【原创】
- 傅里叶分析笔记
- Android——Android实现多级菜单联动操作
- 编程输出1000以内所有素数
- facebook post注册。封号。研究