Libgdx - 非法状态未知位置的异常

我正在使用Android Studio 1.3和libgdx 1.6.2来创建游戏。我想将Google Play服务整合到我的游戏中,我已经在一个步骤中完成了所有工作,因为我之前没有遇到任何问题。但是,这次它给了我一个例外:

java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
        at com.google.android.gms.common.internal.zzi$zza.zzc(Unknown Source)
        at com.google.android.gms.common.internal.zzi$zza.zzr(Unknown Source)
        at com.google.android.gms.common.internal.zzi$zzc.zznQ(Unknown Source)
        at com.google.android.gms.common.internal.zzi$zzb.handleMessage(Unknown Source)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5254)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

所以这是我除了添加baseGameUtils(成功添加)之外所做的更改。

编辑:完整的安卓清单

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

    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/GdxTheme" >
        <activity
            android:name="com.example.app.android.AndroidLauncher"
            android:label="@string/app_name" 
            android:screenOrientation="portrait"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.purplebrain.adbuddiz.sdk.AdBuddizActivity"
            android:theme="@android:style/Theme.Translucent" />
    </application>

</manifest>

这是我的机器人主要活动。

public class AndroidLauncher extends AndroidApplication  implements GameHelper.GameHelperListener{

    private GameHelper gameHelper;
    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (gameHelper == null) {
            gameHelper = new GameHelper(this, GameHelper.CLIENT_GAMES);
        }
        gameHelper.setup(this);

        AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
        initialize(new Cells(new ActionResolver() {
            @Override
            public boolean getSignedInGPGS() {
                return gameHelper.isSignedIn();
            }

            @Override
            public void loginGPGS() {
                try {
                    runOnUiThread(new Runnable() {
                        public void run() {
                            gameHelper.beginUserInitiatedSignIn();
                        }
                    });
                } catch (final Exception ex) {

                }
            }

            @Override
            public void submitScoreGPGS(int score) {
                Games.Leaderboards.submitScore(gameHelper.getApiClient(), "CgkI6ZHYr9IEEAIQBg", score);
            }

            @Override
            public void getLeaderboardGPGS() {
                if (gameHelper.isSignedIn()) {
                    startActivityForResult(Games.Leaderboards.getLeaderboardIntent(gameHelper.getApiClient(), "CgkI6ZHYr9IEEAIQBg "), 100);
                }
                else if (!gameHelper.isConnecting()) {
                    loginGPGS();
                }

            }

            @Override
            public void unlockAchievementGPGS(String achievementId) {
                Games.Achievements.unlock(gameHelper.getApiClient(), achievementId);
            }

            @Override
            public void getAchievementsGPGS() {
                if (gameHelper.isSignedIn()) {
                    startActivityForResult(Games.Achievements.getAchievementsIntent(gameHelper.getApiClient()), 101);
                }
                else if (!gameHelper.isConnecting()) {
                    loginGPGS();
                }

            }


        }), config);
    }

    @Override
    public void onStart(){
        super.onStart();
        gameHelper.onStart(this);
    }
    @Override
    public void onStop(){
        super.onStop();
        gameHelper.onStop();
    }
    @Override
    public void onActivityResult(int request, int response, Intent data) {
        super.onActivityResult(request, response, data);
        gameHelper.onActivityResult(request, response, data);
    }

    @Override
    public void onSignInFailed() {

    }

    @Override
    public void onSignInSucceeded() {

    }
}

我不知道这里出了什么问题。提前致谢。


答案 1

您需要在 标记中使用 。<meta-data><application>AndroidManifest

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

    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/GdxTheme" >
        <activity
            android:name="com.example.app.android.AndroidLauncher"
            android:label="@string/app_name" 
            android:screenOrientation="portrait"
            android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.purplebrain.adbuddiz.sdk.AdBuddizActivity"
            android:theme="@android:style/Theme.Translucent" />

    <meta-data android:name="com.google.android.gms.games.APP_ID"
        android:value="@string/app_id" />
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

    </application>

</manifest>

清除您的数据并在Google Play服务上卸载更新。

然后,重新安装它。


答案 2

推荐