Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/231.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 功能模块中的刀柄_Android_Kotlin_Dagger 2_Dagger Hilt_Dynamic Feature Module - Fatal编程技术网

Android 功能模块中的刀柄

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 当我运行一个

我在android项目中添加了一个动态功能模块。我知道hilt不支持这种类型的模块。我在谷歌文档中找到了解决这个问题的方法

我有一个项目结构如下

  • 应用程序-带应用程序活动的主模块
  • 公地
    • utils-所有android模块都具有通用功能的模块
      • 数据库-包括数据库模块(hilt)
      • 网络-包括http客户端和网络模块(hilt)
      • 注入-包括Mapbox模块依赖项类
  • 核心
  • 特征
    • 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
}