0

我有一个运行良好的 android 项目。它具有三个活动:MainActivity、CorrectAnswerActivity 和 UserFailed。我在 CorrectAnswerActivity 和 UserFailed 上使用 Google Play Services api,因此这些正在扩展 BaseGameUtil。

这一切都很好,直到我认为更改我的包名称是个好主意(因为我更改了我的游戏名称)。因此,现在当您单击 MainActivity 上的按钮时,它将带您进入 Failed 或 Correct,我得到 noclassdeffounderror 就好像它找不到 CorrectAnswerActivity 或 UserFailed。

我用新的包名和提到的所有其他地方更新了我的清单。

08-20 21:45:29.765: E/AndroidRuntime(5549): 
Caused by: java.lang.NoClassDefFoundError: com.blackcrowndev.numbers.CorrectAnswerActivity
08-20 21:45:29.765: E/AndroidRuntime(5549):      at com.blackcrowndev.numbers.MainActivity.onClickGuess(MainActivity.java:254)

我感觉好像有什么关系

public class CorrectAnswerActivity extends BaseGameActivity
implements View.OnClickListener {

但我没有改变图书馆内的任何东西。

谢谢你们的帮助。我真的是 Java 和 Android 开发的新手,所以如果我需要提供更多信息,请告诉我。我会给你我的清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.blackcrowndev.numbers"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Password" >
        <meta-data
            android:name="com.google.android.gms.games.APP_ID"
            android:value="@string/app_id" />

        <activity
            android:name="com.blackcrowndev.numbers.MainActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.blackcrowndev.numbers.CorrectAnswerActivity"
            android:label="@string/title_activity_correct_answer"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.blackcrowndev.numbers.UserFailed"
            android:label="@string/title_activity_user_failed"
            android:screenOrientation="portrait" >
        </activity>
        <activity
            android:name="com.blackcrowndev.numbers.HowToPlay"
            android:label="@string/title_activity_how_to_play"
            android:screenOrientation="portrait">
        </activity>
    </application>

</manifest>
4

3 回答 3

1

右键单击项目,然后转到属性 -> javabuild path -> order export 选择所需并清理您的项目。

于 2013-08-21T03:01:23.480 回答
1

看来您遇到了 ADT 错误。

检查 - https://code.google.com/p/android/issues/detail?id=55304

StackOverflow 中也有一些类似的问答

将扩展从 Activity 更改为 BaseGameActivity 后出现 ClassNotFoundException

知道解决方法是“转到属性->订购并导出应用程序项目并检查所有库项目的'Android Private Libraries'”。(在您的情况下,谷歌播放服务库应设置为“Android 私有库”。

于 2013-08-21T05:16:20.027 回答
0

修改manifest文件中的包名,对应每个class文件,如有不改名!!

于 2013-08-21T05:25:14.393 回答