美文网首页
5.0以下系统java.lang.ClassNotFoundEx

5.0以下系统java.lang.ClassNotFoundEx

作者: 椰子 | 来源:发表于2018-05-17 07:12 被阅读17次

异常信息:

04-23 14:34:41.217 6844-6844/com.incep.kotlin E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.incep.kotlin, PID: 6844
    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{
com.incep.kotlin/incep.view.MainActivity}: 
java.lang.ClassNotFoundException: Didn't find class "incep.view.MainActivity" on path: 
DexPathList[[zip file "/data/app/com.incep.kotlin-1.apk"],
nativeLibraryDirectories=[/data/app-lib/com.incep.kotlin-1, /vendor/lib, /system/lib]]
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
        at android.app.ActivityThread.access$800(ActivityThread.java:157)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5293)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
        at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "incep.view.MainActivity" on path: 
DexPathList[[zip file "/data/app/com.incep.kotlin-1.apk"],
nativeLibraryDirectories=[/data/app-lib/com.incep.kotlin-1, /vendor/lib, /system/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
        at android.app.Instrumentation.newActivity(Instrumentation.java:1079)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2199)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340) 
        at android.app.ActivityThread.access$800(ActivityThread.java:157) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:157) 
        at android.app.ActivityThread.main(ActivityThread.java:5293) 
        at java.lang.reflect.Method.invokeNative(Native Method) 
        at java.lang.reflect.Method.invoke(Method.java:515) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081) 
        at dalvik.system.NativeStart.main(Native Method) 

解决办法:

defaultConfig {
   multiDexEnabled true
}

depenencies {
   compile 'com.android.support:multidex:1.0.1'
}

//AndroidManifest.xml 中的application要实现MultiDexApplication这个类
<application
android:name="android.support.multidex.MultiDexApplication">
</application>

others:
其实你不知道MultiDex到底有多坑
https://blog.csdn.net/u013398380/article/details/73220095?utm_source=itdadao&utm_medium=referral

相关文章

网友评论

      本文标题:5.0以下系统java.lang.ClassNotFoundEx

      本文链接:https://www.haomeiwen.com/subject/mncllftx.html