I'm trying to resuscitate an old codebase.
In one of the activities, the enqueue()
call represented in the code snippet below keeps crashing the app:
WorkManager
.getInstance(requireContext())
.enqueue(updateValues) // updateValues is a WorkRequest
Here's the exception:
java.lang.VerifyError: Verifier rejected class androidx.work.impl.OperationImpl: com.google.common.util.concurrent.ListenableFuture androidx.work.impl.OperationImpl.getResult() failed to verify: com.google.common.util.concurrent.ListenableFuture androidx.work.impl.OperationImpl.getResult(): [0x2] can't resolve returned type 'Unresolved Reference: com.google.common.util.concurrent.ListenableFuture' or 'Unresolved Reference: androidx.work.impl.utils.futures.SettableFuture' (declaration of 'androidx.work.impl.OperationImpl' appears in /data/app/~~KoZa3Uwv5hinF_EqVv8JEA==/com.flesson.tutor.uat-YOfhXEvtwlYyJ7ihgXtB_A==/base.apk)
I have:
2.8.0-alpha02
which is the latest version..but the crash still persists.
Here's the updateValues
WorkRequest:
private val updateValues: WorkRequest by lazy {
OneTimeWorkRequestBuilder<UpdateValuesWorker>()
.setConstraints(
Constraints
.Builder()
.setRequiredNetworkType(NetworkType.CONNECTED)
.build()
)
.setBackoffCriteria(
BackoffPolicy.EXPONENTIAL,
5,
TimeUnit.MINUTES
)
.build()
}
UpdateValuesWorker
just makes a regular API call.
The solution was a tad weird, I admit.
My first step was to update the dependency versions for WorkManager as well as Coroutines to the latest versions (as stated in the question details). After that, I updated the provider<> tag in my AndroidManifest.xml file from this:
<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
tools:node="remove" />
to this:
<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
android:exported="false"
tools:node="merge" />
After that, everything just worked fine.