Android app ClassNotFoundException for main activity-ThrowExceptions

Exception or error:

Most of the devices can run my app but I got this error report :

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{}: java.lang.ClassNotFoundException: in loader dalvik.system.PathClassLoader[/mnt/asec/]
at android.os.Handler.dispatchMessage(
at android.os.Looper.loop(
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: in loader dalvik.system.PathClassLoader[/mnt/asec/]
at dalvik.system.PathClassLoader.findClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
... 11 more

I found there is a related answer:
ClassNotFoundException Android

but the question is, my exception occurs before any line of code i write, so how can I ensure the class loader is loaded?

How to solve:

I had exactly the same problem. Suddenly my app stopped working. I didint make any change to manifest, but with some accident there was missing first row:

<?xml version="1.0" encoding="utf-8"?>

This caused ClassNotFoundException for launcher activity. I was struggling with that for few hours and I overlooked this every time I was checking manifest for possible mistake.

Strange thing happened after I have deleted this row again. Suprise, suprise app was still working. (and I didnt forget to rebuild app)

Hope this help someone to save few hours.


I get this error when my class isn’t correctly defined in the manifest, typically because I haven’t put in the correct name space as in:

    <activity android:name="" ...>

as opposed to

    <activity android:name="MyMainActivity" ...>

Not sure why it would work for you on some devices and not others though.


Please close your eclipse and open. Clean your project and do a refresh. Then run and see.


I had the same issue and the problem was a third party library that is using Android Support Library.


When I updated the library with newer version, the support library was also updated – but not in my project. After that I could not launch the application with this error. After making both libraries to be the same (copy), it was ok.


In eclipse, check Properties>Java Build Path>Source and see if the output folder is always the default (/bin/classes).

For me, this was an issue because of the maven plugin: whenever I right click>Maven>Update Project…>Ok, it changes the output folder of the src folder to target/classes, causing the ClassNotFoundException.


I just ran into this problem. Turns out it was because I had moved my MainActivity into a new package.

What I did was move it from




so in my manifest it looked like this:


Solved it by moving it back into the original package. It can also be solved by renaming your packages correctly:

Eg: com.example.Activity.MainActivity

Hope this helps someone.


I had this problem for the last couple days. I could run my app on every test environment, I could export a release apk, and install and run it on every test environment, but when I uploaded the apk to the play store and installed from the play store the app would fource close throwing ClassNotFoundException. It turned out that in my project I was sending multipart form data to a web api, and to do this requires some external libraries. At first I just included all the mim4j, httpclient, and httpcore .jars (turns out to be a lot of jars).

After deleting almost all of them one by one and seeing if my project would still build I was left with only one jar THAT WAS ACTUALLY REQUIRED. The take away is delete any jars that are not required to build. Then I tested the app and turns out I needed to add one of the jars back because it’s resources were referenced by the one that was required to build the project. Make sure to test every function of your app after deleting jars.

Then I went through each library project I was including and went to right-click on project -> properties -> java build path -> order and export and checked all the boxes FOR EVERY LIBRARY and MY OWN PACKAGE.

Then I did a project -> clean on every project that is included and the main project.

Then I exported the apk and put the package up for beta testing and it finally worked on users devices.


I ran into this problem and it was fixed using this.

I had not checked one external library under “Order and export” and i was getting the error.


None of the answers above worked for me, contributing my solution if it’s going to spare some hours to anyone in the future.

What apparently worked for me was removing an extra support lib v4 jar in my project.

After I updated the support lib via android tools, I had to fix jar mismatches in many libraries I use and point them all to the same jar in the android-sdks folder.

I accidently added it to my project as well, and for some reason it made my MainActivity class not found in runtime, because the jar was also in the android-support-v7-appcompat library I was using.

No errors on eclipse at all.

I removed the jar from my project, and checked the jar in the v7 appcompat library in the export tab so it would be available to my project as well, and voila, app is working.


Thanks to version control, I noticed that I didn’t have these lines in my .classpath xml file:

<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>

These caused Class-not-found for main activity.


I’ve got the same when run Robolectric tests. Actually, test classpath includes jar with, which has not been founded.
A solution in my case is downgrade JAVA_HOME from 10th JDK version, which is used in Maven project.


I made a copy/paste of the following folders to a new project, keeping the same package name, and solved it:

  • ../src/debug
  • ../src/main
  • ../src/release

And finally I added the file dependencies build.gradle.


Leave a Reply

Your email address will not be published. Required fields are marked *