Android ClassNotFoundException: Didn't find class on path

user3129072 picture user3129072 · Jan 4, 2014 · Viewed 87.5k times · Source

I can't find the solution of this error.Can you please give the permanent solution.i have no idea how to solve it can u help me .Thanks

01-04 11:06:42.302: E/AndroidRuntime(1906): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{e.gochat/e.gochat.gochat.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "e.gochat.gochat.MainActivity" on path: DexPathList[[zip file "/data/app/e.gochat-1.apk"],nativeLibraryDirectories=[/data/app-lib/e.gochat-1, /vendor/lib, /system/lib]]
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2102)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.app.ActivityThread.access$700(ActivityThread.java:135)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.os.Handler.dispatchMessage(Handler.java:102)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.os.Looper.loop(Looper.java:137)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.app.ActivityThread.main(ActivityThread.java:4998)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at java.lang.reflect.Method.invokeNative(Native Method)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at java.lang.reflect.Method.invoke(Method.java:515)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at dalvik.system.NativeStart.main(Native Method)
01-04 11:06:42.302: E/AndroidRuntime(1906): Caused by: java.lang.ClassNotFoundException: Didn't find class "e.gochat.gochat.MainActivity" on path: DexPathList[[zip file "/data/app/e.gochat-1.apk"],nativeLibraryDirectories=[/data/app-lib/e.gochat-1, /vendor/lib, /system/lib]]
01-04 11:06:42.302: E/AndroidRuntime(1906):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
01-04 11:06:42.302: E/AndroidRuntime(1906):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2093)
01-04 11:06:42.302: E/AndroidRuntime(1906):     ... 11 more
01-04 11:07:06.772: I/Process(1906): Sending signal. PID: 1906 SIG: 9

This is my app Manifest XML

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="e.gochat"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="18" />
<permission
    android:name="e.gochat.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />

<uses-permission android:name="e.gochat.permission.C2D_MESSAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />

<application
    android:name="e.gochat.Common"
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >


    <activity
        android:name="e.gochat.MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
     <activity android:name="e.gochat.ChatActivity" 
        />
    <activity
        android:name="e.gochat.SettingsActivity"
        android:label="@string/title_activity_settings" />
    <receiver
        android:name="e.gochat.client.GcmBroadcastReceiver"
        android:permission="com.google.android.c2dm.permission.SEND" >
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.RECEIVE" />

            <category android:name="e.gochat" />
        </intent-filter>
    </receiver>
    <provider
        android:name="e.gochat.DataProvider"
        android:authorities="e.gochat.provider" 
        android:exported="false">
    </provider>


</application>

I'm not sure what's wrong here. I've added the .jar file in the java build path. And yet I'm getting this classnotfound exception. The app loads when I import the android.app.Application

Answer

Kishor N R picture Kishor N R · Apr 6, 2017

I have solved this problem by disabling the instant run option of android studio. To disable Instant Run Goto File -> Settings -> Build,Execution, Deployment -> Instant Run -> Uncheck the checkbox for instant run