Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Dagger 2:错误:[ComponentProcessor:MiscError]生成代码的循环依赖项_Android_Dagger 2 - Fatal编程技术网

Android Dagger 2:错误:[ComponentProcessor:MiscError]生成代码的循环依赖项

Android Dagger 2:错误:[ComponentProcessor:MiscError]生成代码的循环依赖项,android,dagger-2,Android,Dagger 2,我正在从事一个项目,其中旧匕首是在代码库中实现的。今天,我尝试将dagger实现优化为dagger 2.2。正如您所知,google更新了dagger库以使该库易于在android中实现,有一些辅助类,如dagger活动、dagger应用程序和dagger片段类 我已经更新了库,但是我被错误缠住了 error: [ComponentProcessor:MiscError] dagger.internal.codegen.ComponentProcessor was unable to pro

我正在从事一个项目,其中旧匕首是在代码库中实现的。今天,我尝试将dagger实现优化为dagger 2.2。正如您所知,google更新了dagger库以使该库易于在android中实现,有一些辅助类,如dagger活动、dagger应用程序和dagger片段类

我已经更新了库,但是我被错误缠住了

 error: [ComponentProcessor:MiscError]
 dagger.internal.codegen.ComponentProcessor was unable to process this
 interface because not all of its dependencies could be resolved. Check
 for compilation errors or a circular dependency with generated code.
 public abstract interface NewAppComponent extends
 dagger.android.AndroidInjector<com.mallconnect.tdm.TDMApplication> {
我检查了一些StackOverflow帖子,但没有找到解决方案


我们如何追踪错误的来源?

我已经解决了评论中建议的循环依赖性问题

如果不浏览
组件中包含的所有模块,就无法解决此问题


当我错误地浏览
活动buildermodule
时,我提供的是
AuthViewModel
而不是
AuthViewModelModule
,在
main片段buildermodule
中,我也在证明
ViewModel
而不是
contributeandroidjector
中的
ViewModel模块无需查看
组件中包含的所有模块
,即可寻址!我已经添加了ActivityBuilderModule所有其他模块都是相同的,它们使用的是旧的Daggerm。我的最佳猜测是
AuthViewModel.class
导致了
循环依赖关系。可能是因为它已被绑定到
ViewModelModule
中。尝试从
ActivityBuilderModule
中删除一次
AuthViewModel.class
,然后重新生成no
AuthViewModelModule.class
仅绑定在
ActivityBuilderModule
@FazalHussain如果我认为这会导致问题,您是否使用
BaseActivity
扩展了
MainActivity
@Singleton
@Component(modules = [AndroidSupportInjectionModule::class,
            ActivityBuilderModule::class,
            AppModule::class,
            RoomModule::class,
            RetrofitModule::class,
            MappedInModule::class,
            ViewModelFactoryModule::class
])
interface NewAppComponent : AndroidInjector<TDMApplication> {

    /**
     * Session manager can be access any where in the application
     */
    fun sessionManager(): SessionManager

    @Component.Builder
    interface Builder {

        /**
         * [BindsInstance] annotation is used for, if you want to bind particular object or instance
         * of an object through the time of component construction
         *
         * @param application The application instance
         *
         * @return The Builder
         */
        @BindsInstance
        fun application(application: Application): Builder


        /**
         *
         * @return the AppComponent
         */
        fun build(): NewAppComponent

    }

}
@Module
public abstract class ActivityBuilderModule {

    @ContributesAndroidInjector(modules = {MainFragmentBuildersModule.class,
            MainViewModelsModule.class})
    abstract Main contributeMainActivity();

    @ContributesAndroidInjector(modules = {AuthViewModel.class})
    abstract BaseActivity contributeBaseActivity();



}