[英]java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/work/R when updating Gradle Android Plugin
I started updating dependencies for an older project of mine, but then noticed that the app does not start after some dep updates - it thows a java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/work/R$bool
exception.我开始更新我的一个旧项目的依赖项,但随后注意到应用程序在一些 dep 更新后没有启动 - 它显示
java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/work/R$bool
异常。 This might happen because on startup I reschedule a Worker to do some periodic IO.这可能是因为在启动时我重新安排了一个 Worker 来做一些周期性的 IO。
I narrowed it down to the com.android.tools.build:gradle:3.5.1
-> com.android.tools.build:gradle:3.6.1
change in build.gradle
and this does correspond with the docs but that does not help much.我将其缩小到
com.android.tools.build:gradle:3.5.1
-> com.android.tools.build:gradle:3.6.1
在build.gradle
更改,这确实与文档相对应,但这并不帮助很大。
A bit more context about the current set up where the problem occurs:有关出现问题的当前设置的更多上下文:
I use the old classpath and version for the work library with implementation "android.arch.work:work-runtime-ktx:1.0.1"
我将旧的类路径和版本用于
implementation "android.arch.work:work-runtime-ktx:1.0.1"
的工作库
I tried reproducing this set up in a test project with no success, which might indicate that this is some kind of cache problem.我尝试在测试项目中重现此设置但没有成功,这可能表明这是某种缓存问题。 I tried removing them with
rm -rf ~/.gradle/caches
but that did not help我尝试用
rm -rf ~/.gradle/caches
删除它们,但这没有帮助
Android Studio also displays this problem in the WorkManagerImpl.java
file (from the work library source) which would indicate that this indeed is not a gradle cache issue Android Studio 还在
WorkManagerImpl.java
文件(来自工作库源)中显示此问题,这表明这确实不是 gradle 缓存问题
EDIT 1: I tried removing the androidx:work
package uses and the this exception is thrown by another support library from the androidx
group.编辑 1:我尝试删除
androidx:work
包使用,并且此异常是由androidx
组中的另一个支持库引发的。 This points me to there being some there being some other funky class processing going on.这让我注意到有一些其他一些时髦的类处理正在进行。
EDIT 2: I've found the solution, and this would apply to any android.support
libraries - a gradle plugin realm-android
was messing up the build, so updating it seems to have fixed the problem.编辑 2:我找到了解决方案,这适用于任何
android.support
库 - 一个 gradle 插件realm-android
搞砸了构建,所以更新它似乎解决了这个问题。 Similar problems might occur with other code-generating plugins.其他代码生成插件可能会出现类似的问题。
Any tips on how to approach this would be appreciated任何有关如何处理此问题的提示将不胜感激
As the OP sayed, it could be any other plugin or dependency as well.正如 OP 所说,它也可以是任何其他插件或依赖项。 In my case, the error came from the ObjectBox plugin.
就我而言,错误来自 ObjectBox 插件。
Updating ObjectBox from 2.5 to 2.6 solved the issue for me.将 ObjectBox 从 2.5 更新到 2.6 为我解决了这个问题。
objectboxVersion = '2.6.0'
However, I needed to add the following lines to my build.gradle for ObjectBox to work again.但是,我需要将以下行添加到我的 build.gradle 中,以便 ObjectBox 再次工作。
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.