5

当我在测试我的应用程序的调试版本时——没关系。在我为 Google Play 版本签名后——它开始为 FC,但有以下例外:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.wiagames.guitartuner/com.wiagames.guitartuner.activities.MainActivity}: java.lang.ClassNotFoundException: com.wiagames.guitartuner.activities.MainActivity
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1983)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
at android.app.ActivityThread.access$600(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.wiagames.guitartuner.activities.MainActivity
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1974)

显现:

 <application android:label="@string/app_name"
                 android:icon="@drawable/ic_launcher">

        <activity android:name=".activities.MainActivity"
                  android:label="@string/app_name"
                  android:configChanges="orientation|keyboardHidden"
                  android:theme="@style/AppTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>

        <activity android:name="com.google.ads.AdActivity"
                  android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

    </application>

如何解决?

4

2 回答 2

3

你能发布你的应用程序清单文件吗?

我怀疑活动的声明不正确。

它应该如下所示:

<activity android:name="com.wiagames.guitartuner.activities.MainActivity" /> 

或者如果你已经有一个包声明,那么它应该像这样:

<activity android:name=".activities.MainActivity" /> 

请注意,您需要在名称值中使用前导句点(即“.”)。

于 2012-12-20T15:12:27.690 回答
2

如果你得到 ClassNotFoundException 你必须编写 Activity 所在的包

    activity android:name="com.wiagames.guitartuner.activities.MainActivity"

您的 Android Manifest.xml 应如下所示:

    <activity android:name="com.wiagames.guitartuner.activities.MainActivity"
              android:label="@string/app_name"
              android:configChanges="orientation|keyboardHidden"
              android:theme="@style/AppTheme">
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

    <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

</application>
于 2012-12-20T15:54:26.160 回答