简体   繁体   English

java.lang.NoClassDefFoundError:更新 Gradle Android 插件时失败的解析:Landroidx/work/R

[英]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.1build.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.

相关问题 java.lang.NoClassDefFoundError:解析失败:Landroidx / core / app / ActivityManagerCompat - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/app/ActivityManagerCompat java.lang.NoClassDefFoundError:解析失败:Landroidx/appcompat/app/AppCompatActivity - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/app/AppCompatActivity java.lang.NoClassDefFoundError:解析失败:Landroidx/core/view/MenuHost; - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/core/view/MenuHost; java.lang.NoClassDefFoundError:解析失败:Landroidx/appcompat/app/AppCompatActivity; - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/appcompat/app/AppCompatActivity; Android Espresso:java.lang.NoClassDefFoundError:解析失败:Landroidx/test/platform/io/FileTestStorage; - Android Espresso: java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/test/platform/io/FileTestStorage; Xamarin.Android 绑定 Java.Lang.NoClassDefFoundError: '解析失败: Landroidx/viewbinding/ViewBinding;' - Xamarin.Android binding Java.Lang.NoClassDefFoundError: 'Failed resolution of: Landroidx/viewbinding/ViewBinding;' java.lang.NoClassDefFoundError:无法解决以下问题:Landroidx / arch / core / util / Cancellable - java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/arch/core/util/Cancellable Java.Lang.NoClassDefFoundError: '解析失败: Landroidx/arch/core/executor/ArchTaskExecutor;' - Java.Lang.NoClassDefFoundError: 'Failed resolution of: Landroidx/arch/core/executor/ArchTaskExecutor;' 将 androidx.room 打包到 aar 库中的项目导致 java.lang.NoClassDefFoundError:解析失败:Landroidx/room/RoomDatabase - Project with androidx.room packed into aar library causes java.lang.NoClassDefFoundError: Failed resolution of: Landroidx/room/RoomDatabase java.lang.noClassDefFoundError:无法解决以下问题:Lcom / facebook / R $ style; - java.lang.noClassDefFoundError: Failed resolution of: Lcom/facebook/R$style;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM