使用minSDK 21构建变量为路径上的类提供ClassNotFoundException:DexPathList

时间:2016-09-12 09:12:32

标签: android dex

我最近在我的应用程序中添加了MultiDex,并且我开始体验日志构建时间,所以我按照android网站上关于multidex的指南进行了操作,并添加了minSDK = 21的prod风格。

切换到devDebug构建版本并尝试运行应用程序后,我得到:

09-12 12:02:15.168 7849-7849/css.myapp.debug E/AndroidRuntime: FATAL EXCEPTION: main
                                                                              Process: css.myapp.debug, PID: 7849
                                                                              java.lang.RuntimeException: Unable to get provider com.facebook.FacebookContentProvider: java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookContentProvider" on path: DexPathList[[zip file "/data/app/css.myapp.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/css.myapp.debug-1/lib/arm64, /vendor/lib64, /system/lib64]]
      at android.app.ActivityThread.installProvider(ActivityThread.java:5156)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
      at android.app.ActivityThread.-wrap1(ActivityThread.java)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
      at android.os.Handler.dispatchMessage(Handler.java:102)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
   Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.FacebookContentProvider" on path: DexPathList[[zip file "/data/app/css.myapp.debug-1/base.apk"],nativeLibraryDirectories=[/data/app/css.myapp.debug-1/lib/arm64, /vendor/lib64, /system/lib64]]
      at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
      at android.app.ActivityThread.installProvider(ActivityThread.java:5141)
      at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) 
      at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) 
      at android.app.ActivityThread.-wrap1(ActivityThread.java) 
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) 
      at android.os.Handler.dispatchMessage(Handler.java:102) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
    Suppressed: java.lang.ClassNotFoundException: com.facebook.FacebookContentProvider
      at java.lang.Class.classForName(Native Method)
      at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
      at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
            ... 12 more
   Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

编辑:

  1. 使用minSDK 16添加风味(与defaultConfig中使用的相同)或
  2. 切换到上一次提交 两者都使应用程序再次运行,没有这个问题。

1 个答案:

答案 0 :(得分:0)

仅当您 targetSdkVersion see documentation时才需要以下内容。

public class MyApplication extends MultiDexApplication

即修复它:

public class MyApplication extends Application