Java.lang.ClassNotFoundException: Could not find class on path: dexpathlist

I am currently working on a project in which I should use exclusively my own ndk. It worked when I try to run the helloworld example from an Irrlicht engine source. Then I try to use it in my project, following the same format of this example. But I got:

03-14 01:40:05.308: E/AndroidRuntime(799): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.irrlicht.example1/android.app.POMActivity}: java.lang.ClassNotFoundException: Didn't find class "android.app.POMActivity" on path: DexPathList[[zip file "/data/app/com.irrlicht.example1-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.irrlicht.example1-2, /system/lib]] 

during the launch of my project.

Here is my main.cpp file:

 #include <android/log.h> #include <jni.h> #include <android_native_app_glue.h> #include "android_tools.h" #ifdef _IRR_ANDROID_PLATFORM_ void android_main(android_app* app) { __android_log_print(4 , "pom" , "nothing"); } 

#endif

in Android.mk:

 LOCAL_PATH := $(call my-dir)/.. IRRLICHT_PROJECT_PATH := $(LOCAL_PATH) include $(CLEAR_VARS) LOCAL_MODULE := Irrlicht LOCAL_SRC_FILES := /home/karthik/Android/Essentials/ogl-es/lib/Android/libIrrlicht.a include $(PREBUILT_STATIC_LIBRARY) include $(CLEAR_VARS) LOCAL_MODULE := HelloWorldMobile1 LOCAL_CFLAGS := -D_IRR_ANDROID_PLATFORM_ -pipe -fno-exceptions -fno-rtti -fstrict-aliasing LOCAL_C_INCLUDES := -I ../../include -I /home/karthik/Android/Essentials/ogl-es/include -I /home/karthik/Android/json/jsoncpp-src-0.5.0/libs/linux-gcc-4.8 -I /home/karthik/Android/json/jsoncpp-src-0.5.0/include/json LOCAL_SRC_FILES := android_tools.cpp main.cpp LOCAL_LDLIBS := -lEGL -llog -lGLESv1_CM -lGLESv2 -lz -landroid -ldl LOCAL_STATIC_LIBRARIES := Irrlicht android_native_app_glue include $(BUILD_SHARED_LIBRARY) $(call import-module,android/native_app_glue) 

And I gave the name Activity in AndroidManifest.xml:

 <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.irrlicht.example1" android:versionCode="1" android:versionName="1.0"> ... <application android:icon="@drawable/irr_icon" android:label="HelloWorldMobile1" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:debuggable="true"> <activity android:name="android.app.POMActivity" android:label="HelloWorldMobile1" android:launchMode="singleTask" android:configChanges="orientation|keyboardHidden" android:screenOrientation="portrait" android:clearTaskOnLaunch="true"> <meta-data android:name="android.app.lib_name" android:value="HelloWorldMobile1" /> 

What mistake am I making here? I will publish the full code, if possible.

+121
java c ++ android android-ndk
Mar 14 '14 at 8:20
source share
32 answers
  • one
  • 2

I tried all possible options, but the result is zero. Finally, I found the right solution, which is useful to me. Just go to the Instant Run mode Go to File β†’ Options β†’ Build, Run, Deploy β†’ Instant Run β†’ Uncheck the box for instant launch . Launch the application once and this apk file works correctly.

+79
Jul 26 '17 at 7:29
source share

I had a similar problem, here is my solution:

  • Right-click on your project and select Properties .
  • Select Java Build Path in the menu on the left.
  • Select the Order and Export tab.
  • In the list, make sure libraries or external banks that are added to the project are marked.
  • Finally, clean the project and run.

You can also check this answer.

+64
Apr 09 '14 at
source share

This seems to be the problem in your case. The relative path of your activity in the manifest is incorrect:

 <activity android:name="android.app.POMActivity" 

replace this with:

 <activity android:name=".POMActivity" 

or

 <activity android:name="com.irrlicht.example1.POMActivity" 
+39
Mar 14 '14 at 8:23
source share

I have to understand the problem just by seeing

dex errors

But to solve the problem took half a day.
I fix this by following the instructions on the Android developers page: https://developer.android.com/studio/build/multidex.html

First add this to your gradle.build file:

 defaultConfig { ... minSdkVersion 14 targetSdkVersion 21 ... // Enabling multidex support. multiDexEnabled true } dependencies { compile 'com.android.support:multidex:1.0.0' } 

Then extend the Application class with the MultiDexApplication class, as indicated in the link above (either declare the application class in AndroidManifest.xml or override the attachBaseContext() function if it is not possible to extend the application class).

This all solved the problem.

+22
May 30 '16 at 13:32
source share

Removing the application on the device and cleaning the design work for me

+22
Jul 07 '16 at 16:59
source share

This exception may also occur if your layout looks like this in your layout:

 <com.example.MyView android:layout_width="match_parent" android:layout_height="match_parent" /> 

and you change the presentation representation from "com.example" to something else, but you will also forget to change it in the layout.

+21
Oct 11 '17 at 23:18
source share

I solved this using the ./gradlew --stop in android studio terminal. After executing this command, clean and rebuild the project.

+12
Oct 13 '16 at 1:58
source share

Just try Clear Project and Rebuild Project .

+12
Sep 14 '17 at 8:56 on
source share
  • delete folder folder
  • reorder libraries
  • clean and rebuild

worked for me.

+11
Jun 13 '14 at 5:51 on
source share

For anyone with multidex support, write this

inside build.gradle

 apply plugin: 'com.android.application' android { defaultConfig { multiDexEnabled true } dexOptions { javaMaxHeapSize "4g" } } dependencies { compile 'com.android.support:appcompat-v7:+' compile 'com.google.android.gms:play-services:+' compile 'com.android.support:multidex:1.0.1' } 

write the EnableMultiDex class as shown below

 import android.content.Context; import android.support.multidex.MultiDexApplication; public class EnableMultiDex extends MultiDexApplication { private static EnableMultiDex enableMultiDex; public static Context context; public EnableMultiDex(){ enableMultiDex=this; } public static EnableMultiDex getEnableMultiDexApp() { return enableMultiDex; } @Override public void onCreate() { super.onCreate(); context = getApplicationContext(); } } 

and in AndroidManifest.xml write this className inside the application tag

  <application android:name="YourPakageName.EnableMultiDex" android:hardwareAccelerated="true" android:icon="@drawable/wowio_launch_logo" android:label="@string/app_name" android:largeHeap="true" tools:node="replace"> 
+10
Jan 05 '17 at 7:26
source share

If the project compiled just before, you can try to clear the cache using:

./gradlew clean

or

./gradlew cleanBuildCache

or for windows

gradlew cleanBuildCache

https://developer.android.com/studio/build/build-cache.html

+9
Sep 06 '17 at 7:17
source share

I came across this problem several times, and they were all resolved by disabling Instant Run .

+8
Apr 10 '18 at 15:22
source share

Just clean your project. It works for me.

+7
Nov 13 '18 at 14:57
source share

When you use multidex, try extending the application class using MultiDexAppication instead of the application and overriding the method below that is required for Android below 5.0 (since support is 5.0 and above for multidex)

 @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(BaseApplication.this); } 

and in the dependencies add this

 compile 'com.android.support:multidex:1.0.1' 
+6
Apr 11 '17 at 17:12
source share

We do not need to configure the Application class , which extends MultiDexApplication . Instead, we can have it on AndroidManifest.xml

 <application android:name="android.support.multidex.MultiDexApplication" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme"> 

And along with this on build.gradle (Module: application),

 defaultConfig { ... // Enabling multidex support. multiDexEnabled true } dependencies { ... compile 'com.android.support:multidex:1.0.2' } 

Thank you

+6
Nov 06 '17 at 6:58
source share

Just change your folder name from lib to libs ,

Then you will see some errors in your project to allow this rightClick in the project>

Properties > Java Build Path > libraries :

Delete the whole library with red marks on it, then apply > ok > then clean the project . TADA sees magic :)

+4
May 05 '14 at 11:58 a.m.
source share

after I tried these answers, I found out another reason for the same Exception that I had to add a library that I use manually in my main library through

 Right click on my main library > Properties > Android > Go to the very bottom of the screen and click (Add) > Select my other library that caused the crash > Apply 

before this solution, I used the "Fix Project setup" from inside the .java file in eclipse, but that didn’t work, so I had to add it manually here and it worked

+3
Sep 29 '15 at 13:13
source share

I only got this crash on Samsung Lollipop devices and this solution worked for me.

 dexOptions { preDexLibraries false } 

I am posting this answer here because this question is currently the highest Google search result for this crash, and none of the answers above helped me.

+3
Dec 29 '17 at 18:12
source share

In my case, this problem arose because of Kotlin. In my existing code, there was a class that was written by Kotlin. I built the application, it was installed and, as soon as the first action was opened, the application crashed. in logcat this error was shown. Then I updated my version of Kotlin from the Kotlin website in the gradle application file. Build the application again, and then it worked fine.

+3
Jun 14 '18 at 11:46
source share

The following solution worked for me ...

I tried everything that is mentioned above, but still have not launched my application. I have a native application running on the latest version of Gradle 4+ and Android Studio.

I had a problem in which if I run reactive-native launch-android, it fails with the problem saying that it cannot find the MainApplication class ... i.e. ClassNotFoundException

I was able to solve this problem when I updated my gradle.properties to use the D8 compiler.

I added:

android.enableD8 = TRUE

to my gradle.properties

Details of the document are here: https://android-developers.googleblog.com/2017/08/next-generation-dex-compiler-now-in.html

+2
Apr 02 '18 at 16:18
source share

If you included minifyEnabled and shrinkResources in true in the application file of your application. You need to add the following line to the proguard-rules.pro file

-keep class com.yourpackage_name. ** {*; }

because minification removed some important classes in our apk file.

+2
Jun 28 '18 at 7:50
source share

If you get this error after removing some gradle dependency, check your manifest and make sure you delete all entries matching this dependency.

+1
Nov 21 '16 at 20:56
source share

In accordance with my perplexity, I get this problem after installing version 2.1 for Android version 2.1 to 2.3 due to the instant function that my application does not launch when I copy apk from the output and put it on the SD card. For this problem, I create apk from the make build apk build option in android studio.

+1
Jun 23 '17 at 11:04 on
source share

I had this problem before, and the comments here have helped in the past, but this time it is not. I checked my ProGuard configuration and deleted the following lines, after which it worked, so ProGuard may be related to this error:

  -optimizationpasses 5 -overloadaggressively -repackageclasses '' -allowaccessmodification -dontskipnonpubliclibraryclassmembers 
+1
Jul 30 '18 at 8:54
source share

I had the same error and some answers mislead me regarding the newbie problem. I had the wrong package in my custom view descriptor, as shown below. Hope this helps someone.

 <com.my.app.wrong.package.MyActivity android:id="@+id/myActivity" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:paddingTop="16dp" android:paddingBottom="8dp" android:gravity="left" /> 
+1
Aug 28 '18 at 11:36
source share

Ashik Abbas's answer (disable Instant Run ) works for me, but I need Instant Run , in the end I found a solution that is useful to me. just disable minifyEnabled . go to build.gradle (Module: app) in the debug block and disable minifyEnabled :

 debug { minifyEnabled false } 
+1
Oct 18 '18 at 12:00
source share

In my case, I used the old namespace library while my project was set up using androidx.

The solution was to replace the android.support.design.widget.BottomNavigationView component with a suitable one to exit the support library: com.google.android.material.bottomnavigation.BottomNavigationView .

+1
Apr 27 '19 at 20:57
source share

For me, the problem appeared after I created a signed APK. To fix this, I generated a new debug apk using Run / Build APK. After that Run (cmd + r) works again without this error.

0
Mar 18 '18 at 16:36
source share

I ran into the same problem. I tried everything possible in a day, but nothing worked. The dependency that caused the problem used the lower compilation sdk, target sdk and min sdk. I created a library module for the project, copied all the sources and compared the SDK versions with the SDK versions of the application. And finally it worked like a charm.

0
Aug 24 '18 at 11:06
source share

You can also see that the class was not found when Unmarshalling Android Intent Parcelable or Android E / Parcel οΉ• The class was not found when unmarshalling (only on Samsung Tab3) , but no tips from these topics helped me. I even rewrote a class for sale.

0
Feb 18 '19 at 15:18
source share
  • one
  • 2



All Articles