我使用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(已经成功添加)之外,我改变了这一点。
修改 完整的Android Manifest
<?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() {
}
}
我不知道这里有什么不对。 提前谢谢。
答案 0 :(得分:4)
您需要在<meta-data>
的{{1}}标记内使用<application>
。
AndroidManifest
清除您的数据并卸载Google Play服务上的更新。
然后,重新安装。