Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android ClassNotFoundException: Didn't find class

Tags:

android

    02-28 01:49:27.741: E/AndroidRuntime(23024): FATAL EXCEPTION: main
    02-28 01:49:27.741: E/AndroidRuntime(23024): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.appname.android/com.appname.android.ITCutiesReaderAppActivity}: java.lang.ClassNotFoundException: Didn't find class "com.appname.android.ITCutiesReaderAppActivity" on path: /data/app/com.appname.android-2.apk
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
...
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at dalvik.system.NativeStart.main(Native Method)
    02-28 01:49:27.741: E/AndroidRuntime(23024): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.appname.android.ITCutiesReaderAppActivity" on path: /data/app/com.appname.android-2.apk
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
    02-28 01:49:27.741: E/AndroidRuntime(23024):    ... 11 more

I started to get this error after i delete the extra folder in app folder with same app files (and change app name, fixed names in all files). How can i fix this?

Here is manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.appname.android"
    android:versionCode="3"
    android:versionName="1.0" >
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name=".ITCutiesReaderAppActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".ItemDescriptionActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
            </activity>
    </application>
</manifest>
like image 427
milesh Avatar asked Feb 27 '13 23:02

milesh


2 Answers

You do have a package mismatch error, it needs to be:

package="com.haber29.android.reader"

Since reader is the next subpackage and this is the subpackage that contains the Activities.

And don't forget, you can specify the fully qualified name for each Activity, to prevent confusion:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.haber29.android"
    android:versionCode="3"
    android:versionName="1.0" >
    <uses-sdk android:minSdkVersion="7" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name="com.haber29.android.reader.ITCutiesReaderAppActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.haber29.android.reader.ItemDescriptionActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
            </intent-filter>
            </activity>
    </application>
</manifest>
like image 177
A--C Avatar answered Nov 18 '22 04:11

A--C


I have the same problem today,because my library include the android-support-v4.jar not matching with my demo. I deleted the library's android-support-v4.jar and copied my demo's jar putting it in my library and it started to work.

like image 20
Simon Avatar answered Nov 18 '22 02:11

Simon