关于广播报 RuntimeException : Didn't find class on path: DexPathList 等问题解决

我们常常会遇到dex超出方法数的问题,所以很多人都会采用android.support-multidex进行解决,但是今天又遇到这么一个错误** Didn't find class on path: DexPathList ** RuntimeException DexPathList ContentProvider

起因

项目升级了 compileSdkVersion版本从22 ->28 还有 *com.android.support. ** 等包

然后在低版本报错 如下

E/AndroidRuntime: FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to get provider me.jessyan.autosize.InitProvider: java.lang.ClassNotFoundException: Didn't find class "me.jessyan.autosize.InitProvider" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/2.apk"],nativeLibraryDirectories=[/data/app-lib/2, /vendor/lib, /system/lib, /system/lib/egl]]
        at android.app.ActivityThread.installProvider(ActivityThread.java:4882)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485)
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425)
        at android.app.ActivityThread.access$1300(ActivityThread.java:141)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5103)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:773)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "me.jessyan.autosize.InitProvider" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/2.apk"],nativeLibraryDirectories=[/data/app-lib/2, /vendor/lib, /system/lib, /system/lib/egl]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
        at android.app.ActivityThread.installProvider(ActivityThread.java:4867)
        at android.app.ActivityThread.installContentProviders(ActivityThread.java:4485) 
        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4425) 
        at android.app.ActivityThread.access$1300(ActivityThread.java:141) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:137) 
        at android.app.ActivityThread.main(ActivityThread.java:5103) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:525) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:773) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:589) 
        at dalvik.system.NativeStart.main(Native Method) 

原因 multiDex 的问题

解决方式

1、在dependencies中增加

api 'com.android.support:multidex:1.0.2@aar'

2、在Application中增加

 @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
    }

defaultConfig 下的 multiDexEnabled true 无须删除
重新build 运行即可。
如果还不可以 执行File - Sync 在试即可。

你可能感兴趣的:(关于广播报 RuntimeException : Didn't find class on path: DexPathList 等问题解决)