2

Ich kann keine Verbindung zu Google Play Game-Diensten in einem nativen Emulator herstellen, die gleiche APK funktioniert jedoch in Bluestacks.Google Play-Spieldienste + Emulator

Bis jetzt fordert die App eine Liste der Errungenschaften des Benutzers über Games.Achievements.getAchievementsIntent an. Diese Errungenschaften werden erfolgreich in Bluestacks angezeigt, der Bildschirm des nativen Emulators bleibt jedoch leer.

Um ehrlich zu sein, war es eine Überraschung, als Bluestacks die Errungenschaften des Benutzers (wie unten gezeigt) anzeigte, da ich keine Präsentationslogik implementiert hatte.

app running in Bluestacks

Ich baue Abhängigkeiten mit Google Play-Dienste 9.6.1:

compile 'com.google.android.gms:play-services-games:9.6.1' 

Emulator läuft ein Systemabbild mit API 24 + Google APIs

ich eine automanaged Instanz bin mit von GoogleApiClient, der versucht, eine Verbindung herzustellen, aber dann fehlschlägt. Ich habe zahlreiche Korrekturen vergeblich versucht.

@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(); 
} 

Ergebnis im 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 {[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 

Antwort

0

Ich bin mir nicht sicher, ob dies helfen wird, aber ich merkte, in Ihrem Fehlerprotokoll, dass es heißt:

"You have not specified a View to use as content view for popups." 

prüfen diese SO thread die schlägt vor:

Verwenden Sie SetViewForPopUps Methode

Games.setViewForPopups(getApiClient(), getWindow().getDecorView().findViewById(android.R.id.content)); 

Ein anderer Weg, dies zu tun ist:

setViewForPopups in Ihrem mGoogleApiClient Objekt definieren.

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(); 

auf den Code der Suche, es scheint, dass Sie dies nicht hinzugefügt haben. Hier finden Sie zusätzliche Informationen unter setViewForPopups method.

Verwandte Themen