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

5.6k Views Asked by At

I am making an android project game which I recently added some libraries to this project, and since I did I get the same error:

dex2oat : Failed to create oat file: /data/dalvik-cache/arm/data@app@***.*******.*************[email protected]@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.access$1100(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.access$1800(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

I believe I should say that all the projects / library projects are using the same target "android-23". I have checked all the answers on StackOverflow and other websites and could'nt find any answer that solved my problem. Thanks for helping!

EDIT

The project is written on Netbeans IDE framework, not on android studio and the project isnt using gradle. here is the AndroidManifest.xml file:

<?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>

EDIT #2

After a little bit of digging it seems like there is a problem with the dex2oat trying to create oat file:

dex2oat : Failed to create oat file: /data/dalvik-cache/arm/data@app@***.*******.*************[email protected]@classes.dex: Permission denied

I have no idea what to do now. Referenced libraries: Google Play Services and Android Support v13. If I remove the libraries the project works fine... so what is the problem?

2

There are 2 best solutions below

1
On BEST ANSWER

Alright, so after a long time of searching it turns out the problem was with the sdk manager of android - I downloaded all the build tools when I only had to download one. So I deleted all the unnecessary packages and the project is now working fine. Thanks for those who tried to help!

0
On

My such problem was solved by:- 1)Clean 2) Build --> Build Apk. And this Apk was working fine earlier i was just coping from app->build->output->apk.