Open
Description
After updating to Kotlin 2.1.20 and Hilt 2.56.1, I'm getting the following error at compile time:
error: Unable to read Kotlin metadata due to unsupported metadata kind: null. public final class XStatusWorker extends androidx.work.CoroutineWorker {
This happens in a class that uses @HiltWorker with @AssistedInject constructor and also has @Inject lateinit var fields.
import android.content.Context
import androidx.hilt.work.HiltWorker
import androidx.work.CoroutineWorker
import androidx.work.WorkerParameters
import dagger.assisted.Assisted
import dagger.assisted.AssistedInject
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import javax.inject.Inject
@HiltWorker
internal class XWorker @AssistedInject constructor(
@Assisted context: Context,
@Assisted params: WorkerParameters,
) : CoroutineWorker(context, params) {
@Inject
internal lateinit var localDataSource: XLocalDataSource
@Inject
internal lateinit var remoteDataSource: XRemoteDataSource
override suspend fun doWork(): Result = withContext(Dispatchers.IO) {
// ...
}
}
This setup was working fine with Kotlin 2.0.x and Hilt 2.51+, and it broke only after moving to Kotlin 2.1.20.
Repro info:
Kotlin: 2.1.20
AGP: 8.9.1
Hilt: 2.56.1
By the way Im using Kapt not KSP
Metadata
Metadata
Assignees
Labels
No labels