2016-12-06 65 views
2

我收到此錯誤從我的發揮開發者控制檯: -錯誤,同時登錄到谷歌玩遊戲服務:looper.prepare()不能被稱爲

java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare() 
    at android.os.Handler.<init>(Handler.java:121) 
    at android.app.Dialog.<init>(Dialog.java:101) 
    at android.app.AlertDialog.<init>(AlertDialog.java:63) 
    at android.app.AlertDialog.<init>(AlertDialog.java:59) 
    at android.app.AlertDialog$Builder.create(AlertDialog.java:793) 
    at com.google.android.gms.common.GoogleApiAvailability.zza(Unknown Source) 
    at com.google.android.gms.common.GoogleApiAvailability.getErrorDialog(Unknown Source) 
    at com.google.android.gms.common.GooglePlayServicesUtil.getErrorDialog(Unknown Source) 
    at com.google.example.games.basegameutils.GameHelper.showFailureDialog(GameHelper.java:953) 
    at com.google.example.games.basegameutils.GameHelper.showFailureDialog(GameHelper.java:920) 
    at com.google.example.games.basegameutils.GameHelper.giveUp(GameHelper.java:898) 
    at com.google.example.games.basegameutils.GameHelper.resolveConnectionResult(GameHelper.java:865) 
    at com.google.example.games.basegameutils.GameHelper.beginUserInitiatedSignIn(GameHelper.java:662) 
    at com.sdsmdg.cycle.AndroidLauncher.signIn(AndroidLauncher.java:90) 
    at com.sdsmdg.cycle.screens.SplashScreen.<init>(SplashScreen.java:41) 
    at com.sdsmdg.cycle.CGame.create(CGame.java:23) 
    at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:275) 
    at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1381) 
    at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1138) 

它看起來像它崩潰,當用戶無法登錄谷歌播放服務,但我無法弄清楚這個問題的解決方案。

下面是遊戲的源代碼: - https://github.com/harshit211997/Hitball

回答

0

你正試圖從後臺線程顯示AlertDialog。爲了顯示你的對話框添加Looper.prepare()或顯示與mainUiThread對話框。

+0

我知道這一點,但如何做到這一點。我打電話給gameHelper.beginUserInitiatedSignIn();從我的主要活動和休息是由玩遊戲庫照顧 –

1

您是否嘗試過:的

runOnUiThread(new Runnable() { @Override public void run() { gameHelper.beginUserInitiatedSignIn(); } });

,而不是僅僅

gameHelper.beginUserInitiatedSignIn();

相關問題