gpt4 book ai didi

android - Dagger 2 : error: [ComponentProcessor:MiscError] circular dependency with generated code

转载 作者:行者123 更新时间:2023-12-04 23:59:57 29 4
gpt4 key购买 nike

我正在做一个项目,旧 Dagger 是在代码库中实现的。今天,我尝试将 dagger 实现优化到 dagger 2.2。如您所知,Google 更新了 Dagger 库以使该库易于在 Android 中实现,其中有一些辅助类,例如 Dagger Activity、Dagger Application 和 Dagger Fragment 类。

我已经更新了库,但我卡在了错误提示中

 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> {

新应用组件

@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

}

}

ActivityBuilderModule

@Module
public abstract class ActivityBuilderModule {

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

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



}

我查看了一些 StackOverflow 帖子,但我还没有找到解决方案

Dagger2 Circular Dependency Error

Dagger 2.15: Appcomponent - was unable to process this interface

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

最佳答案

对我来说,这是因为我有一个数据类,其中未指定顶部的包名称,因此,当导入该数据类时,它被导入为import DataClassName 而不是完整的分类名称,因此导致循环依赖

关于android - Dagger 2 : error: [ComponentProcessor:MiscError] circular dependency with generated code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59947224/

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