1

我在 Android 开发者帐户中获得了下面的堆栈跟踪。此错误仅发生一次。

java.lang.RuntimeException: Unable to instantiate application com.mysite.myapp.TestApplication: java.lang.ClassNotFoundException: com.mysite.myapp.TestApplication in loader dalvik.system.PathClassLoader[/data/app-private/com.mysite.myapp-2.apk]
at android.app.LoadedApk.makeApplication(LoadedApk.java:466)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3268)
at android.app.ActivityThread.access$2200(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:973)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3691)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.myapp.myapp.TestApplication in loader dalvik.system.PathClassLoader[/data/app-private/com.mysite.myapp-2.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newApplication(Instrumentation.java:945)
at android.app.LoadedApk.makeApplication(LoadedApk.java:461)
... 11 more

在我的清单文件中,我声明了com.mysite.myapp.TestApplication. 我的清单文件如下所示:

<application
    android:name="com.mysite.myapp.TestApplication"
    android:icon="@drawable/app_icon"
    android:label="@string/app_name"
    android:theme="@style/Theme.myapp" >
    <activity
        android:name="com.mysite.myapp.ActivityDashboard"
        android:configChanges="orientation|keyboard"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
...
4

2 回答 2

1

如果您的主页是 ActivityDashboard.java 插入如下,或者如果 TestApplication.java 将 .ActivityDashboard 替换为 .TestApplication 在活动标签中

<package name="com.mysite.myapp"
    <application
        android:name="TestApplication"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:theme="@style/Theme.myapp" >

        <activity android:name=".ActivityDashboard" android:configChanges="orientation|keyboard"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    ......
    </application>
于 2012-05-09T05:42:27.520 回答
0
android:name="com.mysite.myapp.ActivityDashboard"

将清单中的上述内容替换thr为以下内容。

 android:name=".ActivityDashboard"

或者:

android:name="com.mysite.myapp.TestApplication.ActivityDashboard"
于 2012-05-09T02:54:57.900 回答