Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture

huangapple go评论102阅读模式
英文:

Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture

问题

<br>
我尝试在我的一个项目中实现WorkManager API。应用程序成功编译,但当我尝试使用WorkManager执行一些工作时,它抛出以下运行时错误:

运行时错误
无法解析:Landroidx/work/impl/utils/futures/AbstractFuture;

根据我对这个错误的了解,它发生在在编译时可用的某个类在运行时不可用的情况下。但是在我反编译我的APK时,所有必要的类(包括 androidx.work.impl.utils.futures.AbstractFuture)都存在!我尝试了work-runtime库的版本2.3.4、2.4.0和2.5.0_Alpha01,但似乎都不起作用。如果有人能帮助我解决这个问题,那将非常有帮助。 =)


注:供您参考,我正在处理的项目非常旧,不幸的是,它仍在使用Apache Ant。而且,由于这将影响整个架构并且需要大量时间,我们短时间内不易迁移到Gradle。因此,任何建议在build.gradle中进行更改的解决方案都可能不太有帮助。 Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture


编辑:如果有人需要查看ADB日志:

...
09-05 20:47:01.536 25688 25688 W System.err: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture;
09-05 20:47:01.536 25688 25688 W System.err:    at androidx.work.WorkManager.initialize(WorkManager.java:210)
09-05 20:47:01.536 25688 25688 W System.err:    at androidx.work.impl.WorkManagerInitializer.onCreate(WorkManagerInitializer.java:40)
09-05 20:47:01.537 25688 25688 W System.err:    at android.content.ContentProvider.attachInfo(ContentProvider.java:2102)
09-05 20:47:01.537 25688 25688 W System.err:    at android.content.ContentProvider.attachInfo(ContentProvider.java:2076)
09-05 20:47:01.537 25688 25688 W System.err:    at android.app.ActivityThread.installProvider(ActivityThread.java:7430)
09-05 20:47:01.537 25688 25688 W System.err:    at android.app.ActivityThread.installContentProviders(ActivityThread.java:6934)
09-05 20:47:01.537 25688 25688 W System.err:    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6851)
09-05 20:47:01.537 25688 25688 W System.err:    at android.app.ActivityThread.access$1600(ActivityThread.java:242)
09-05 20:47:01.537 25688 25688 W System.err:    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
09-05 20:47:01.537 25688 25688 W System.err:    at android.os.Handler.dispatchMessage(Handler.java:107)
09-05 20:47:01.537 25688 25688 W System.err:    at android.os.Looper.loop(Looper.java:227)
09-05 20:47:01.537 25688 25688 W System.err:    at android.app.ActivityThread.main(ActivityThread.java:7822)
09-05 20:47:01.537 25688 25688 W System.err:    at java.lang.reflect.Method.invoke(Native Method)
09-05 20:47:01.537 25688 25688 W System.err:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
09-05 20:47:01.537 25688 25688 W System.err:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)
09-05 20:47:01.537 25688 25688 W System.err: Caused by: java.lang.ClassNotFoundException: androidx.work.impl.utils.futures.AbstractFuture
09-05 20:47:01.537 25688 25688 W System.err:    ... 15 more
...

<details>
<summary>英文:</summary>

&lt;br&gt;
I tried to implement the WorkManager API in one of my projects. The app compiles successfully, but when I try to execute some work using WorkManager, it throws the below runtime error:

Runtime Error
Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture;


---


What I know of this error is that it occurs when some class that was available during compile time isn&#39;t available during runtime. But this doesn&#39;t seem to be the case with me, as when I decompiled my APK, all the necessary classes (including `androidx.work.impl.utils.futures.AbstractFuture`) were present there! I tried version 2.3.4, 2.4.0, and 2.5.0_Alpha01 of the work-runtime library, but none of them seemed to work. It&#39;d be really helpful if someone could help me solve this issue. =)

---

Note: FYI, the project I&#39;m working on is very old, and unfortunately, it still uses Apache Ant. Also, it won&#39;t be easy for us to migrate to Gradle anytime soon as it&#39;ll affect the whole architecture and take a huge amount of time. So, any solution suggesting changes in build.gradle won&#39;t be quite helpful. :)

---

**EDIT**: In case anyone needs to see the ADB log:

...
09-05 20:47:01.536 25688 25688 W System.err: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/work/impl/utils/futures/AbstractFuture;
09-05 20:47:01.536 25688 25688 W System.err: at androidx.work.WorkManager.initialize(WorkManager.java:210)
09-05 20:47:01.536 25688 25688 W System.err: at androidx.work.impl.WorkManagerInitializer.onCreate(WorkManagerInitializer.java:40)
09-05 20:47:01.537 25688 25688 W System.err: at android.content.ContentProvider.attachInfo(ContentProvider.java:2102)
09-05 20:47:01.537 25688 25688 W System.err: at android.content.ContentProvider.attachInfo(ContentProvider.java:2076)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.installProvider(ActivityThread.java:7430)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.installContentProviders(ActivityThread.java:6934)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6851)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.access$1600(ActivityThread.java:242)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
09-05 20:47:01.537 25688 25688 W System.err: at android.os.Handler.dispatchMessage(Handler.java:107)
09-05 20:47:01.537 25688 25688 W System.err: at android.os.Looper.loop(Looper.java:227)
09-05 20:47:01.537 25688 25688 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7822)
09-05 20:47:01.537 25688 25688 W System.err: at java.lang.reflect.Method.invoke(Native Method)
09-05 20:47:01.537 25688 25688 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
09-05 20:47:01.537 25688 25688 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)
09-05 20:47:01.537 25688 25688 W System.err: Caused by: java.lang.ClassNotFoundException: androidx.work.impl.utils.futures.AbstractFuture
09-05 20:47:01.537 25688 25688 W System.err: ... 15 more
...

答案1

得分: 3

我今天修复了一个类似的问题,问题实际上是缺少了 ListenableFuture,尽管异常头部看起来与你的情况相同。

我之前在我的构建文件中添加了这个:

implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

我这样做是为了避免类重复错误,因为Guava是从其他地方导入的(还请参阅这个问题)。
在那个依赖不再依赖Guava之后,之前修复问题的导入现在反而引起了问题。再次移除它就解决了这个问题。

英文:

I fixed a similar issue today where the issue was actually a missing ListenableFuture, even though the exception head looked the same as yours.

I had added this to my build file previously:

implementation &#39;com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava&#39;

I did this to avoid a class duplication error, since Guava was imported from elsewhere (also see this question).
After that dependency stopped depending on Guava, the import that previously fixed an issue now caused an issue itself. Removing it again fixed the problem.

答案2

得分: 1

我遇到过类似的问题。这是由依赖冲突引起的。我分享一下我解决这个问题的方法。使用这个依赖 implementation 'com.google.guava:guava:28.2-android',并确保在 build.gradle 中移除这个部分:

configurations.all {
    resolutionStrategy {
        exclude group: 'com.google.guava', module: 'listenablefuture'
    }
}
英文:

I have faced the similar issue. This happens on dependency
conflict.I'm sharing what I have done to resolve this. Using this
dependency &quot;implementation &#39;com.google.guava:guava:28.2-android&quot;
and make sure to remove this in build.gradle

      configurations.all {
            resolutionStrategy {
                exclude group: &#39;com.google.guava&#39;, module: &#39;listenablefuture&#39;
            }
        }

huangapple
  • 本文由 发表于 2020年9月5日 18:33:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/63752933.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定