我正在尝试测试我的第一个谷歌Api应用。我使用谷歌播放服务客户端lib连接到谷歌+ API。我做了一个简单的连接,在我的genymotion 4.4.4(包括谷歌应用程序)中运行它后,一个Toast消息说 - “发生内部错误”,logcat也没有显示任何错误。我添加了对Internet,帐户和manifest中的凭证。我在控制台中很好地集成了SHA1和项目包,在here中添加了播放服务版本等的元数据,添加了编译' com.google.android.gms:play-services-加上:6.5.87 '在gradle中。 我最近使用android studio。 这是我的代码 -
public class MainActivity extends FragmentActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mClient;
// Bool to track whether the app is already resolving an error
private boolean mResolvingError = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
// Create a GoogleApiClient instance for google+
mClient = new GoogleApiClient.Builder(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
protected void onStart() {
super.onStart();
if (!mResolvingError) {
mClient.connect();
}
}
@Override
protected void onStop() {
mClient.disconnect();
super.onStop();
}
@Override
public void onConnected(Bundle bundle) {
// this shows a string log message but it shows nothing
L.m(" I M CONNECTED");
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(ConnectionResult result) {
// this shows a string log message AND IT SHOWS UP
L.m(" I M NOT CONNECTED");
}
}
这是我的控制台(它只是一个测试应用程序,所以无需隐藏)
答案 0 :(得分:0)
我找到了解决方案。我很久以前改变了我的.android的默认位置,我的PC上有两个操作系统,有两个Android工作室。因此,我发现我从WRONG调试密钥库获取证书。叹!!我为此浪费了3天......但对于那些可能没有相同问题的人,请查看您的Google控制台选项卡中的同意屏幕,查看是否提到了产品名称和电子邮件地址。它也可能导致相同的错误。