2014-04-01 139 views
1

我已經檢查了幾個不同的問題,如thisAndroid的 - 谷歌遊戲服務,遊戲客戶端,運行時錯誤

我想在實現一個谷歌的標誌,並已參考https://developers.google.com/games/services/training/signin/,但無法弄清楚如何解決此錯誤

目前,我有我的清單文件中的下列元數據

 <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"/> 

我logcat的錯誤看起來像:

- 04-01 15:25:28.461: E/AndroidRuntime(30017): FATAL EXCEPTION: main 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information. 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at com.google.android.gms.internal.eh$h.b(Unknown Source) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at com.google.android.gms.internal.eh$h.a(Unknown Source) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at com.google.android.gms.internal.eh$b.ec(Unknown Source) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at com.google.android.gms.internal.eh$a.handleMessage(Unknown Source) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at android.os.Handler.dispatchMessage(Handler.java:99) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at android.os.Looper.loop(Looper.java:137) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at android.app.ActivityThread.main(ActivityThread.java:5419) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at java.lang.reflect.Method.invokeNative(Native Method) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at java.lang.reflect.Method.invoke(Method.java:525) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
- 04-01 15:25:28.461: E/AndroidRuntime(30017): at dalvik.system.NativeStart.main(Native Method) 

我也越來越警告早些時候:

- 04-01 15:45:45.408: W/PopupManager(1075): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view. 

我不知道這有什麼關係呢,我試着在OnCreate()覆蓋,並呼籲

setViewForPopups() 

但eclipse不顯示此方法存在。

我現在的MainActivity看起來像

public class MainActivity extends BaseGameActivity implements OnClickListener { 

boolean mExplicitSignOut = false; 
boolean mInSignInFlow = false; 

GoogleApiClient mClient; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    GameView gameView = (GameView) findViewById(R.id.game); 

    GoogleApiClient.Builder builder = 
      new GoogleApiClient.Builder(this); 
     builder.addApi(Games.API) 
       .addApi(Plus.API) 
       .addApi(AppStateManager.API) 
       .addScope(Games.SCOPE_GAMES) 
       .addScope(Plus.SCOPE_PLUS_LOGIN) 
       .addScope(AppStateManager.SCOPE_APP_STATE); 
     mClient = builder.build(); 

} 

@Override 
protected void onStart() { 
    super.onStart(); 
    if (!mInSignInFlow && !mExplicitSignOut) { 
     // auto sign in 
     mClient.connect(); 
    } 
} 

@Override 
public void onSignInFailed() { 
    // TODO SignInFailed 
    Toast.makeText(this, "Sign in Failed", Toast.LENGTH_LONG).show(); 

} 

@Override 
public void onSignInSucceeded() { 
    // TODO SignInSucceeded 
    Toast.makeText(this, "Sign in Succeeded", Toast.LENGTH_LONG).show(); 

} 

@Override 
public void onClick(View v) { 
    // TODO onClick 
    Toast.makeText(this, "Clicked", Toast.LENGTH_LONG).show(); 

} 
} 
+0

你是否設法解決這個問題?我有同樣的問題 –

+0

不完全確定,但我相信這是因爲我還沒有成爲Google開發者帳戶。他們給你一定的代碼來訪問他們的數據庫。 – Codes

回答

2

確保你有你的清單文件中的所有3元數據標籤 -

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

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

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