java.lang.ClassNotFoundException: 未在路径 DexPathList 上找到 class ...

java.lang.ClassNotFoundException: Didn't find class ... on path: DexPathList

我正在制作一个 android 项目游戏,我最近向该项目添加了一些库,但由于我这样做,我得到了同样的错误:

dex2oat : Failed to create oat file: /data/dalvik-cache/arm/data@app@***.*******.*************-2@base.apk@classes.dex: Permission denied
    java.lang.ClassNotFoundException: Didn't find class "***.*******.*************.MainActivity" on path: DexPathList[[zip file "/data/app/***.*******.*************-1/base.apk"],nativeLibraryDirectories=[/data/app/***.*******.*************-1/lib/arm, /vendor/lib, /system/lib]]
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3132)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.app.ActivityThread.access00(ActivityThread.java:229)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:102)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:148)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:7325)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
03-25 10:34:07.084 15904 15904 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.compgal.stealthsmiley.MainActivity" on path: DexPathList[[zip file "/data/app/com.compgal.stealthsmiley-1/base.apk"],nativeLibraryDirectories=[/data/app/com.compgal.stealthsmiley-1/lib/arm, /vendor/lib, /system/lib]]
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.app.Instrumentation.newActivity(Instrumentation.java:1096)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3122)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        ... 9 more
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        Suppressed: java.io.IOException: Failed to open dex files from /data/app/com.compgal.stealthsmiley-1/base.apk
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.DexFile.openDexFileNative(Native Method)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.DexFile.openDexFile(DexFile.java:295)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.DexFile.<init>(DexFile.java:80)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.DexFile.<init>(DexFile.java:59)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.DexPathList.loadDexFile(DexPathList.java:279)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.DexPathList.makePathElements(DexPathList.java:248)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.DexPathList.<init>(DexPathList.java:120)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:48)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:65)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:86)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:47)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at android.app.LoadedApk.getClassLoader(LoadedApk.java:438)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at android.app.LoadedApk.makeApplication(LoadedApk.java:663)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6395)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at android.app.ActivityThread.access00(ActivityThread.java:229)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1887)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                ... 6 more
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        Suppressed: java.lang.ClassNotFoundException: ***.*******.*************.MainActivity
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at java.lang.Class.classForName(Native Method)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
03-25 10:34:07.084 15904 15904 E AndroidRuntime:                ... 12 more
03-25 10:34:07.084 15904 15904 E AndroidRuntime:        Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

我相信我应该说所有项目/库项目都使用相同的目标 "android-23"。我检查了 Whosebug 和其他网站上的所有答案,但找不到解决我问题的任何答案。 感谢您的帮助!

编辑

该项目是在 Netbeans IDE 框架上编写的,而不是在 android studio 上编写的,并且该项目未使用 gradle。 这是 AndroidManifest.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="***.*******.*************"
          android:versionCode="7"
          android:versionName="1.5">
    <application android:label="@string/app_name" android:icon="@drawable/icon"
    >
        <meta-data android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
        <activity 
            android:screenOrientation="landscape"
            android:name="MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

编辑#2

经过一些挖掘后,似乎 dex2oat 尝试创建 oat 文件时出现问题:

dex2oat : Failed to create oat file: /data/dalvik-cache/arm/data@app@***.*******.*************-2@base.apk@classes.dex: Permission denied

我现在不知道该怎么办。 引用的库:Google Play 服务和 Android 支持 v13。 如果我删除库,项目工作正常...那么问题是什么?

好吧,找了半天发现问题出在android的sdk管理器上——我下载了所有的构建工具,而我只需要下载一个。 所以我删除了所有不必要的包,项目现在运行良好。 感谢那些试图提供帮助的人!

我的此类问题已通过以下方式解决:- 1) 清理 2) 构建 --> 构建 Apk。这个 Apk 之前运行良好,我只是从 app->build->output->apk 处理。