Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

338
Views
java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/Math8 when upgrading Gradle and Android Gradle Plugin

I'm working on an Android app with a Gradle version of 7.1.1 and an Android Gradle Plugin version of 7.0.0. When I upgrade to Gradle version 7.2 and Android Gradle Plugin version 7.1.1, I get the following error.

2022-03-02 17:15:47.072 25300-25300/... E/AndroidRuntime: FATAL EXCEPTION: main
    Process: ..., PID: 25300
    java.lang.NoClassDefFoundError: Failed resolution of: Ljava/lang/Math8;
        at j$.time.Instant.ofEpochSecond(Instant.java:328)
        at j$.time.Instant.<clinit>(Instant.java:232)
        at j$.time.Instant.ofEpochMilli(Instant.java:344)
        ...
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "java.lang.Math8" on path: DexPathList[[zip file "/data/app/...-NbMXeOj8LumN03n4IMK5Cw==/base.apk"],nativeLibraryDirectories=[/data/app/...-NbMXeOj8LumN03n4IMK5Cw==/lib/x86, /data/app/...-NbMXeOj8LumN03n4IMK5Cw==/base.apk!/lib/x86, /system/lib, /system/product/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at j$.time.Instant.ofEpochSecond(Instant.java:328) 
        at j$.time.Instant.<clinit>(Instant.java:232) 
        at j$.time.Instant.ofEpochMilli(Instant.java:344) 
        ...
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) 
        at android.os.Handler.handleCallback(Handler.java:883) 
        at android.os.Handler.dispatchMessage(Handler.java:100) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

The error is coming from this code:

fun toLocalStartOfDay(date: Long): Instant = Instant.ofEpochMilli(date)
    .atZone(ZoneId.systemDefault())
    .withHour(0)
    .withMinute(0)
    .withSecond(0)
    .withNano(0)
    .toInstant()

The build.gradle file is set to target JVM 1.8 with desugaring.

compileOptions {
    coreLibraryDesugaringEnabled = true
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
    jvmTarget = '1.8'
}

The desugar_jdk_libs version is set to 1.0.9.

versions.androidDesugaringVersion = '1.0.9'
support.android_desugaring = "com.android.tools:desugar_jdk_libs:$versions.androidDesugaringVersion"

Why would upgrading cause this error?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The sugar removal affects "a subset of java.time ", so updating to the latest version of desugar_jdk_libs should fix the problem. At the time of publication, the latest version is 1.1.5 .

References

  • Java 8+ API sugar removal support (Android Gradle plugin 4.0.0+)
  • desugar_jdk_libs (Maven)
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!