Q:在 Android 7.1.1 或更低版本上遇到异常 java.lang.ClassNotFoundException: Didn’t find class “java.time.Duration”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Caused by java.lang.ClassNotFoundException: Didn't find class "java.time.Duration" on path: DexPathList[[zip file "/data/app/com.******.******/base.apk", zip file "/data/app/com.******.******-1/split_config.arm64_v8a.apk"],nativeLibraryDirectories=[/data/app/com.******.******-1/lib/arm64, /data/app/com.******.******-1/base.apk!/lib/arm64-v8a, /data/app/com.******.******-1/split_config.arm64_v8a.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:380) at java.lang.ClassLoader.loadClass(ClassLoader.java:312) at com.google.android.gms.ads.identifier.a.a(SourceFile:1) at com.google.android.gms.ads.identifier.zzd.<clinit>(SourceFile:10) at com.google.android.gms.ads.identifier.zzd.zza(SourceFile:1) at com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo(SourceFile:42) at com.applovin.impl.v.collectGoogleAdvertisingInfo(SourceFile:19) // <- 关键堆栈信息 at com.applovin.impl.v.c(SourceFile:1) at com.applovin.impl.v.a(SourceFile:9) at com.applovin.impl.v.b(SourceFile:1) at com.applovin.impl.g1.b(SourceFile:1) at com.applovin.impl.g1.c(SourceFile:1) at com.applovin.impl.P0.run(SourceFile:1) at java.lang.Thread.run(Thread.java:761)
dependencies { ... // For AGP 7.4+ coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3") }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// app 或者 launcher 的 build.gradle android { ... compileOptions { ... // Flag to enable support for the new language APIs coreLibraryDesugaringEnabled true // Sets Java compatibility to Java 8 sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
dependencies { ... // For AGP 7.4+ coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.3' }