android ClassNotFoundException:没找到类

时间:2013-02-27 23:55:19

标签: 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

我删除app文件夹中包含相同应用程序文件的额外文件夹(并更改应用程序名称,所有文件中的固定名称)后,我开始收到此错误。我该如何解决这个问题?

这是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>

3 个答案:

答案 0 :(得分:17)

包错配错误,需要:

package="com.haber29.android.reader"

由于reader是下一个子包,是包含活动的子包。

不要忘记,您可以为每个活动指定完全限定名称,以防止混淆:

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

答案 1 :(得分:0)

我今天遇到同样的问题,因为我的库包含的android-support-v4.jar与我的演示不匹配。我删除了库的android-support-v4.jar并复制了我的demo的jar,将它放入我的库中,它开始工作。

答案 2 :(得分:0)

就我而言,我的防病毒软件(适用于Mac的Avira)在每次构建后都会抓取dex文件并将其隔离。停止Avira之后,我的项目即会构建并运行。