我为Android编写了一个程序。在Google Play控制台中,我已启用Google Play服务。在我想要连接到他们的程序中。在Google Play开发者控制台中,我已将我的帐户添加到测试中。服务GooglePlay已发布。很遗憾,我无法连接到Google Play服务。我总是收到消息“无连接”。我的程序中是否有问题,或者我在Google Play控制台中设置了错误? 我附加了“manifest.xml”的片段,活动文本和Google控制台的屏幕截图。无法连接到Google游戏服务
请帮帮我!根据Google Play上的描述,我做了所有事情,但两周后我找不到解决方案。
问候,gravedg
文件的片段 “的Manifest.xml ”:
<meta-data android:name="com.google.android.gms.games.APP_ID" (my app ID is here) android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
片段文件的“ Test1Activity.java”:
package pl.(... here is my package name ...);
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.games.Games;
import com.google.android.gms.plus.Plus;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.Toast;
topublic class Test1Activity extends AppCompatActivity
implements ConnectionCallbacks, OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addApi(Games.API)
.addScope(Games.SCOPE_GAMES)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onStop() {
mGoogleApiClient.disconnect();
super.onStop();
}
@Override
public void onConnected(Bundle connectionHint) {
Toast.makeText(getApplicationContext(), "Connection OK", Toast.LENGTH_LONG).show();
}
@Override
public void onConnectionSuspended(int cause) {
Toast.makeText(getApplicationContext(), "Connection Suspended", Toast.LENGTH_LONG).show();
}
@Override
public void onConnectionFailed(ConnectionResult result) {
Toast.makeText(getApplicationContext(), "No connection", Toast.LENGTH_LONG).show();
}
Google Developer Console - services enabled
Google Play Developer Console - services published
太棒了!有用。非常感谢您的回答,jlopez。 :) – gravedg
我很乐意帮助你,所以如果答案帮助你,你能把它标记为正确吗? – jlopez
要做到这一点,我需要15点的声望。目前我有11分。我会记住的。我会尽可能标记它。 – gravedg