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

查看:43
本文介绍了“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>

我尝试更改应用程序启动的活动,但这也不起作用.Multidex 在 gradle 设置中启用.

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.

推荐答案

我终于设法解决了这个问题.原来,虽然我在 gradle 设置中启用了 MultiDex

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'
   ...
}

我忘记将它添加到 AndroidManifest.xml 中

I had forgotten to add it in the AndroidManifest.xml with

<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天全站免登陆