工人:java.lang.verifyError:验证者拒绝类androidx.work.impl.operationimpl

发布于 2025-01-21 21:16:18 字数 1488 浏览 4 评论 0原文

我正在尝试恢复旧代码库。

在其中一项活动中,enqueue()在下面的代码段中表示的调用一直在崩溃应用程序:

WorkManager
    .getInstance(requireContext())
    .enqueue(updateValues) // updateValues is a WorkRequest

以下是例外:

java.lang.verifyError:verifier拒绝类androidx.work.impl.operationImpl:com.google.common.util.concurrent.listenable.listenablefuture androidx.work.impl.operationImpl.operationImpl.getResult()未能验证:com.google:com.google。 common.util.concurrent.listenableFuture androidx.work.impl.operationImpl.getResult():[0x2]无法解决返回的类型'未解决的参考:com.google.common.util.concurrent.concurrent.concurrent.listenable.listenable.listenablefuture 。 apk)

tor拥有:

  • 将工人的依赖性版本更新为2.8.0-alpha02,它是最新版本的
  • Minsdk更新为21(从19)
  • 使用JDK 11
  • 升级的jdk 11升级的target_sdk和compile_sdk和31
  • 升级的kotlin版本至1.6.0.0.6.0
  • 无效的缓存并重新启动

..但是崩溃仍然存在。

这是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只是进行常规的API调用。

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:

  • Updated the dependency version for WorkManager to 2.8.0-alpha02 which is the latest version
  • Updated minSdk to 21 (from 19)
  • Used JDK 11
  • Upgraded TARGET_SDK and COMPILE_SDK to 31
  • Upgraded Kotlin version to 1.6.0
  • Invalidate cache and restart

..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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

请叫√我孤独 2025-01-28 21:16:18

我承认,解决方案有点奇怪。

我的第一步是将Workmanager的依赖版本以及Coroutines更新为最新版本(如问题细节所述)。之后,我更新了提供商Lt;&gt;在我的 androidmanifest.xml 文件中标记:到此

<provider
    android:name="androidx.work.impl.WorkManagerInitializer"
    android:authorities="${applicationId}.workmanager-init"
    tools:node="remove" />

<provider
    android:name="androidx.startup.InitializationProvider"
    android:authorities="${applicationId}.androidx-startup"
    android:exported="false"
    tools:node="merge" />

之后,一切都很好。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文