java.lang.VerifyError: Verifier rejected class androidx.work.impl.OperationImpl

  android, kotlin, verifyerror, worker

I’m developing an application that allows the user to upload a file to the internet. I’m trying to implement this with OneTimeWorkRequest. However, when I click the upload button, LogCat always shows the following error.

Here are the error messages:

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/~~wwXoGn1_zibHvdnZEPqJmQ==/com.fileupload.filesharing.upfile-8mjIh0hTXF8nmso-vqkPfA==/base.apk)

2021-03-03 12:15:19.703 5606-5606/com.fileupload.filesharing.upfile E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.fileupload.filesharing.upfile, PID: 5606
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/~~2mwYw7ZqWx8NXS-JcNx2qw==/com.fileupload.filesharing.upfile-5nJ6pJA_yY7IdWoI0FLy_Q==/base.apk)
    at androidx.work.impl.utils.EnqueueRunnable.<init>(EnqueueRunnable.java:79)
    at androidx.work.impl.WorkContinuationImpl.enqueue(WorkContinuationImpl.java:186)
    at androidx.work.impl.WorkManagerImpl.enqueueUniquePeriodicWork(WorkManagerImpl.java:421)
    at com.fileupload.filesharing.upfile.util.DailyNotificationScheduler.run(DailyNotificationScheduler.kt:45)
    at com.fileupload.filesharing.upfile.ui.HomeFragment.onActivityResult(HomeFragment.kt:109)
    at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:170)
    at com.fileupload.filesharing.upfile.MainActivity.onActivityResult(MainActivity.kt:102)
    at android.app.Activity.dispatchActivityResult(Activity.java:8316)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5206)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:5254)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2246)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:233)
    at android.app.ActivityThread.main(ActivityThread.java:8010)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
2021-03-03 12:15:23.804 5606-5606/com.fileupload.filesharing.upfile I/Process: Sending signal. PID: 5606 SIG: 9

Here is my code:

binding.homeFragmentProgress.btnUpload.setOnClickListener { 
    val data = workDataOf(UploadWorker.KEY_URI to filePath)

    val constraints = Constraints.Builder()
        .setRequiredNetworkType(NetworkType.CONNECTED)
        .build()

    val uploadTask = OneTimeWorkRequest.Builder(UploadWorker::class.java)
        .setConstraints(constraints)
        .setInputData(data)
        .addTag(TAG_UPLOAD_WORKER)
        .build()

    WorkManager.getInstance(requireContext()).enqueue(uploadTask)
    WorkManager.getInstance(requireContext()).getWorkInfoByIdLiveData(uploadTask.id)
        .observe(viewLifecycleOwner, { workInfo ->
            if (workInfo != null && workInfo.state.isFinished) {
                val outputData = workInfo.outputData
                val url = outputData.getString(UploadWorker.KEY_RESULT_URL) ?: ""
                val days = outputData.getInt(UploadWorker.KEY_RESULT_DAYS, 14)
                Timber.i("url: $url, days: $days")
            }
        })
}

UploadWorker.kt

class UploadWorker(context: Context, params: WorkerParameters) : CoroutineWorker(context, params) {

    companion object {
        const val TAG_UPLOAD_WORKER = "uploadworker"
        const val KEY_URI = "file_uri"
        const val KEY_RESULT_URL = "file_url"
        const val KEY_RESULT_DAYS = "days"
    }

    override suspend fun doWork(): Result {
        return try {
            Timber.i("upload(file) called")
            Result.success(workDataOf(KEY_RESULT_URL to "test", KEY_RESULT_DAYS to 12))
        } catch (throwable: Throwable) {
            throwable.printStackTrace()
            Result.failure()
        }
    }
}

Source: Android Questions

LEAVE A COMMENT