无法使用 @WorkerInject 注入 Worker
Cannot inject Worker using @WorkerInject
我正在尝试将数据注入我的 Worker,但 @WorkerInject
给了我一个 unresolved reference
。
请记住,我在 gradle:
中定义了这些
def hilt_version = '2.38.1'
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
def hilt_worker_version = '1.0.0'
implementation "androidx.hilt:hilt-work:$hilt_worker_version"
kapt "androidx.hilt:hilt-compiler:$hilt_worker_version"
这是我的工人class:
class MyWorker @WorkerInject constructor(
@Assisted val context: Context,
@Assisted workerParams: WorkerParameters
) :
Worker(context, workerParams) { ... }
有一种新的注释方式class:
@HiltWorker
class MyWorker @AssisstedInject constructor(
@Assisted val context: Context,
@Assisted workerParams: WorkerParameters
) :
Worker(context, workerParams) { ... }
我正在尝试将数据注入我的 Worker,但 @WorkerInject
给了我一个 unresolved reference
。
请记住,我在 gradle:
def hilt_version = '2.38.1'
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
def hilt_worker_version = '1.0.0'
implementation "androidx.hilt:hilt-work:$hilt_worker_version"
kapt "androidx.hilt:hilt-compiler:$hilt_worker_version"
这是我的工人class:
class MyWorker @WorkerInject constructor(
@Assisted val context: Context,
@Assisted workerParams: WorkerParameters
) :
Worker(context, workerParams) { ... }
有一种新的注释方式class:
@HiltWorker
class MyWorker @AssisstedInject constructor(
@Assisted val context: Context,
@Assisted workerParams: WorkerParameters
) :
Worker(context, workerParams) { ... }