java.lang.NoClassDefFoundError:无法解决以下问题:Lkotlinx /协程/ experimental / CompletableDeferredKt

时间:2019-02-18 07:38:30

标签: android kotlin kotlinx.coroutines

在按照here的说明添加kotlin协程之前,我的应用程序运行良好。当我单击一个浮动按钮从该lib中打开另一个活动时,出现此错误。删除协程后,应用程序运行正常。

我已经尝试了多种解决方案,例如:

  1. 禁用即时运行。
  2. 清理并重建
  3. 添加minifyEnabled false来调试buildType。
  4. 添加multiDex

但是没有一个。

 android {
compileSdkVersion 28
defaultConfig {
    ...
    minSdkVersion 17
    targetSdkVersion 28
    multiDexEnabled true
    ...
   }
 }

 dependencies {
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation "org.jetbrains.anko:anko:$anko_version"
implementation "org.jetbrains.anko:anko-design:$anko_version"

implementation 'com.fxn769:pix:1.2.5'
implementation 'com.android.support:multidex:1.0.3'
....
 }

踪迹

2019-02-18 10:01:10.097 9523-9523/com.APPIDHERE E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.APPIDHERE, PID: 9523
    java.lang.NoClassDefFoundError: Failed resolution of: Lkotlinx/coroutines/experimental/CompletableDeferredKt;
        at io.fotoapparat.hardware.CameraDevice.<init>(CameraDevice.kt:48)
        at io.fotoapparat.hardware.Device.<init>(Device.kt:39)
        at io.fotoapparat.hardware.Device.<init>(Device.kt:34)
        at io.fotoapparat.Fotoapparat.<init>(Fotoapparat.kt:55)
        at io.fotoapparat.Fotoapparat.<init>(Fotoapparat.kt:48)
        at io.fotoapparat.FotoapparatBuilder.buildInternal(FotoapparatBuilder.kt:190)
        at io.fotoapparat.FotoapparatBuilder.build(FotoapparatBuilder.kt:179)
        at com.fxn.pix.Pix.initialize(Pix.java:373)
        at com.fxn.pix.Pix.onCreate(Pix.java:325)
        at android.app.Activity.performCreate(Activity.java:7136)
        at android.app.Activity.performCreate(Activity.java:7127)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "kotlinx.coroutines.experimental.CompletableDeferredKt" on path: DexPathList[[zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/base.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_dependencies_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_resources_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_0_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_1_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_2_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_3_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_4_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_5_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_6_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_7_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_8_apk.apk", zip file "/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/lib/x86, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at io.fotoapparat.hardware.CameraDevice.<init>(CameraDevice.kt:48) 
        at io.fotoapparat.hardware.Device.<init>(Device.kt:39) 
        at io.fotoapparat.hardware.Device.<init>(Device.kt:34) 
        at io.fotoapparat.Fotoapparat.<init>(Fotoapparat.kt:55) 
        at io.fotoapparat.Fotoapparat.<init>(Fotoapparat.kt:48) 
        at io.fotoapparat.FotoapparatBuilder.buildInternal(FotoapparatBuilder.kt:190) 
        at io.fotoapparat.FotoapparatBuilder.build(FotoapparatBuilder.kt:179) 
        at com.fxn.pix.Pix.initialize(Pix.java:373) 
        at com.fxn.pix.Pix.onCreate(Pix.java:325) 
        at android.app.Activity.performCreate(Activity.java:7136) 
        at android.app.Activity.performCreate(Activity.java:7127) 
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271) 
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893) 
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048) 
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:193) 
        at android.app.ActivityThread.main(ActivityThread.java:6669) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 
        Suppressed: java.io.IOException: No original dex files found for dex location /data/app/com.APPIDHERE-EfujhYqtoKYpsUMLZOt1TQ==/split_lib_resources_apk.apk
        at dalvik.system.DexFile.openDexFileNative(Native Method)
        at dalvik.system.DexFile.openDexFile(DexFile.java:354)
        at dalvik.system.DexFile.<init>(DexFile.java:101)
        at dalvik.system.DexFile.<init>(DexFile.java:75)
        at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
        at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
        at dalvik.system.DexPathList.<init>(DexPathList.java:164)
        at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
2019-02-18 10:01:10.097 9523-9523/com.APPIDHERE E/AndroidRuntime:     at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
        at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
        at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
        at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
        at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
        at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
        at android.app.LoadedApk.getResources(LoadedApk.java:1032)
        at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
        at android.app.ActivityThread.access$1100(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
                ... 6 more

1 个答案:

答案 0 :(得分:0)

实验协程用于Fotoapparat所依赖的PixImagePicker的旧版本中。参见here

尽管Fotoapparat已更新,所以不再使用它们,并且PixImagePicker似乎也在使用最新版本的Fotoapparat

也许在Github上引起他们的问题。

Fotoapparat PixImagePicker