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. This might happen because on startup I reschedule a Worker to do some periodic 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.
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"
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
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
EDIT 1: I tried removing the androidx:work
package uses and the this exception is thrown by another support library from the androidx
group. 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. 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. In my case, the error came from the ObjectBox plugin.
Updating ObjectBox from 2.5 to 2.6 solved the issue for me.
objectboxVersion = '2.6.0'
However, I needed to add the following lines to my build.gradle for ObjectBox to work again.
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8
}