Android 功能模块中的刀柄
我在android项目中添加了一个动态功能模块。我知道hilt不支持这种类型的模块。我在谷歌文档中找到了解决这个问题的方法 我有一个项目结构如下Android 功能模块中的刀柄,android,kotlin,dagger-2,dagger-hilt,dynamic-feature-module,Android,Kotlin,Dagger 2,Dagger Hilt,Dynamic Feature Module,我在android项目中添加了一个动态功能模块。我知道hilt不支持这种类型的模块。我在谷歌文档中找到了解决这个问题的方法 我有一个项目结构如下 应用程序-带应用程序活动的主模块 公地 utils-所有android模块都具有通用功能的模块 数据库-包括数据库模块(hilt) 网络-包括http客户端和网络模块(hilt) 注入-包括Mapbox模块依赖项类 核心 特征 mapboxFeature-包括MapboxComponent和MapBoxModule 当我运行一个
- 应用程序-带应用程序活动的主模块
- 公地
- utils-所有android模块都具有通用功能的模块
- 数据库-包括数据库模块(hilt)
- 网络-包括http客户端和网络模块(hilt)
- 注入-包括Mapbox模块依赖项类
- utils-所有android模块都具有通用功能的模块
- 核心
- 特征
- mapboxFeature-包括MapboxComponent和MapBoxModule
> Task :app:kaptDebugKotlin
C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideDatabase(android.content.Context)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideTaskDao(com.apator.database.AppDatabase)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideTaskDbRepository(com.apator.utils.database.data.dao.TaskDao)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^error: Cannot inject members into qualified types
> Task :app:kaptDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
@EntryPoint
@InstallIn(ApplicationComponent::class)
interface MapboxModuleDependencies {
fun provideTaskDbRepository(): TaskDbRepository
}
有人知道问题出在哪里吗?在
MapboxModuleDependencies
中,您应该只定义TaskDbRepository
,如下所示:
> Task :app:kaptDebugKotlin
C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideDatabase(android.content.Context)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideTaskDao(com.apator.database.AppDatabase)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideTaskDbRepository(com.apator.utils.database.data.dao.TaskDao)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^error: Cannot inject members into qualified types
> Task :app:kaptDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
@EntryPoint
@InstallIn(ApplicationComponent::class)
interface MapboxModuleDependencies {
fun provideTaskDbRepository(): TaskDbRepository
}
override fun onCreate(savedInstanceState: Bundle?) {
fun setDaggerMapboxComponent() {
DaggerMapboxComponent.builder()
.context(requireContext())
.appDependencies(
EntryPointAccessors.fromApplication(
requireContext(),
MapboxModuleDependencies::class.java
)
)
.build()
.inject(this)
}
...
> Task :app:kaptDebugKotlin
C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideDatabase(android.content.Context)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideTaskDao(com.apator.database.AppDatabase)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^C:\Users\piotrro\Desktop\wfm-mobile\app\build\generated\source\kapt\debug\com\apator\wfm\App_HiltComponents.java:173: error: [com.apator.utils.injection.MapboxModuleDependencies.provideTaskDbRepository(com.apator.utils.database.data.dao.TaskDao)] Members injection methods may only return the injected type or void.
public abstract static class SingletonC implements MapboxModuleDependencies,
^error: Cannot inject members into qualified types
> Task :app:kaptDebugKotlin FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
> java.lang.reflect.InvocationTargetException (no error message)
@EntryPoint
@InstallIn(ApplicationComponent::class)
interface MapboxModuleDependencies {
fun provideTaskDbRepository(): TaskDbRepository
}