android ClassNotFoundException:找不到类 [英] android ClassNotFoundException: Didn't find class

查看:69
本文介绍了android ClassNotFoundException:找不到类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    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?

这是manifest.xml

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>

推荐答案

有程序包不匹配错误,它必须为:

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

package="com.haber29.android.reader"

由于 reader 是下一个子程序包,而 this 是包含活动"的子程序包.

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>

这篇关于android ClassNotFoundException:找不到类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆