"ClassNotFoundException:在路径DexPathList上找不到类"在API 19上 [英] "ClassNotFoundException: Didn't find class on path DexPathList" on API 19

查看:87
本文介绍了"ClassNotFoundException:在路径DexPathList上找不到类"在API 19上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个具有目标SDK版本24和最低版本19的Android应用.它在较高的API级别上运行良好,但是当尝试在API级别19上运行时,它崩溃并出现以下错误:

I am making an Android app with targeted SDK version 24 and minimum version 19. It's working fine on the higher API levels but when trying to run it on API level 19 it crashes with the following error:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{se.android/se.android.SplashScreenActivity}: java.lang.ClassNotFoundException: Didn't find class "se.android.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/se.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/se.android-2, /vendor/lib, /system/lib]]
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                  at android.app.ActivityThread.access$800(ActivityThread.java:135)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:136)
                  at android.app.ActivityThread.main(ActivityThread.java:5017)
                  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:779)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                  at dalvik.system.NativeStart.main(Native Method)
               Caused by: java.lang.ClassNotFoundException: Didn't find class "se.android.SplashScreenActivity" on path: DexPathList[[zip file "/data/app/se.android-2.apk"],nativeLibraryDirectories=[/data/app-lib/se.android-2, /vendor/lib, /system/lib]]
                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
                  at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
                  at android.app.ActivityThread.access$800(ActivityThread.java:135) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:136) 
                  at android.app.ActivityThread.main(ActivityThread.java:5017) 
                  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:779) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
                  at dalvik.system.NativeStart.main(Native Method) 

有问题的活动在清单文件中设置:

The activity in question is set up in the manifest file:

<activity
        android:name=".SplashScreenActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/Theme.AppCompat.NoActionBar">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

</activity>

我已经尝试更改应用开始的活动,但是这也不起作用.在gradle设置中启用了Multidex.

I have tried changing which activity the app starts on but that doesn't work either. Multidex is enabled in the gradle settings.

我曾尝试清理它并从存储库中重新加载它,但是它根本无法正常工作.

I have tried cleaning it and reloading it from the repository but it just won't work.

推荐答案

我终于设法解决了这个问题.原来,当我使用

I finally managed to solve the problem. Turned out that while I had enabled MultiDex in the gradle settings with

defaultConfig {
   multiDexEnabled true
   ...
}

并使用

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

我忘了用

<application
   ...
   android:name="android.support.multidex.MultiDexApplication"
   ...
>
   ...
</application>

添加该部分后,它现在可以在API级别19上运行.

After adding that part it now works on API level 19.

这篇关于"ClassNotFoundException:在路径DexPathList上找不到类"在API 19上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆