I am unable to connect to Google Play Game Services in a native emulator, however, the same apk works in Bluestacks.
So far the app requests a list of the user's achievements via Games.Achievements.getAchievementsIntent . These achievements are successfully displayed in Bluestacks, however, the native emulator screen remains blank.
To be honest, it came as a surprise when Bluestacks displayed the user's achievements (as shown below) as I had not implemented any presentation logic.
I am building dependencies with Google Play Services 9.6.1:
compile 'com.google.android.gms:play-services-games:9.6.1'
Emulator is running a system image with API 24 + Google APIs
I am using an automanaged instance of GoogleApiClient which attempts to connect but then fails. I have tried numerous fixes to no avail.
@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();
}
Result in Android Monitor:
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 {0=com.google.android.gms.internal.zzqa$zza@e9fa141}
[ 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: android.os.BinderProxy@6889c40}, message=null}
D/onActivityResult: resultCode = 0
I'm not sure if this will help but I noticed in your error log that it says:
"You have not specified a View to use as content view for popups."
Check this SO thread which suggests:
use setViewForPopUps method
Games.setViewForPopups(getApiClient(), getWindow().getDecorView().findViewById(android.R.id.content));
Another way to do this is to:
define setViewForPopups in your mGoogleApiClient object.
mGoogleApiClient = new GoogleApiClient.Builder(getApplicationContext())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
.addApi(Games.API).addScope(Games.SCOPE_GAMES)
.addApi(Drive.API).addScope(Drive.SCOPE_APPFOLDER)
.setViewForPopups(findViewById(android.R.id.content))
.build();
Looking at your code, it seems you haven't added this. Here's additional reading on setViewForPopups method .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.