我無法在本機模擬器中連接到Google Play遊戲服務,但是,相同的apk在Bluestack中使用。Google Play遊戲服務+模擬器
到目前爲止,該應用程序通過Games.Achievements.getAchievementsIntent來請求用戶的成就列表。這些成就已成功顯示在Bluestack中,但是,本機模擬器屏幕保持空白。
說實話,當Bluestacks顯示用戶的成就(如下所示)時,我沒有實現任何表示邏輯,這讓人感到意外。
我建立依賴與谷歌播放服務9.6.1:
compile 'com.google.android.gms:play-services-games:9.6.1'
模擬器運行的系統映像與API 24層+谷歌的API
我使用的是自動管理實例的GoogleApiClient嘗試連接但失敗。我嘗試了無數修補程序無濟於事。
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this,
this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Games.API)
.addScope(Games.SCOPE_GAMES)
.build();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.d("onActivityResult", "resultCode = " + resultCode);
if (resultCode == GamesActivityResultCodes.RESULT_RECONNECT_REQUIRED) {
mGoogleApiClient.connect();
}
}
@Override
public void onConnected(@Nullable Bundle bundle) {
Log.d("onConnected", "onConnected");
startActivityForResult(Games.Achievements.getAchievementsIntent(mGoogleApiClient), MY_REQ_CODE);
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d("onConnectionFailed", "onConnectionFailed");
mGoogleApiClient.connect();
}
結果在Android的顯示器:
Connected to process 7907 on device Nexus_5X_API_24_GApps [emulator-5554]
W/System: ClassLoader referenced unknown path: /data/app/goc.dma.cprach.gameofchairs-1/lib/x86
W/PopupManager: You have not specified a View to use as content view for popups. Falling back to the Activity content view. Note that this may not work as expected in multi-screen environments
D/AutoManageHelper: starting AutoManage for client 0 false false
D/onStart: onStart
D/AutoManageHelper: onStart true {[email protected]}
[ 10-20 03:00:11.990 1490: 1511 D/ ]
HostConnection::get() New Host Connection established 0x8c3f9680, tid 1511
W/gralloc_ranchu: Gralloc pipe failed
[ 10-20 03:00:12.089 7907: 7907 D/ ]
HostConnection::get() New Host Connection established 0xa438dac0, tid 7907
I/OpenGLRenderer: Initialized EGL, version 1.4
D/OpenGLRenderer: Swap behavior 1
D/onConnectionFailed: onConnectionFailed
D/AutoManageHelper: beginFailureResolution for ConnectionResult{statusCode=RESOLUTION_REQUIRED, resolution=PendingIntent{20c0bc3: [email protected]}, message=null}
D/onActivityResult: resultCode = 0