0

我正在尝试测试我的第一个 google Api 应用程序。我正在使用 google play 服务客户端库连接到 google+ API。我做了一个简单的连接,在我的 genymotion 4.4.4(包括谷歌应用程序)中运行它后,一条 toast 消息说 - “发生内部错误”,logcat 也没有显示错误。我添加了互联网、帐户和清单中的凭据。我在控制台中很好地集成了 SHA1 和项目包,在此处添加了播放服务版本等的元数据,添加了 compile ' com.google.android.gms:play-services-plus:6.5.87 ' in毕业。我正在使用最新的 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");  
    }


}

这是我的控制台(它只是一个测试应用程序,所以没什么可隐藏的) 在此处输入图像描述

4

1 回答 1

0

I found the solution. I changed the default location of my .android a long ago and there are two OS in my PC with two Android studio. Hence, I found that I was getting the certificate from the WRONG debug keystore. Sigh!! I wasted 3 days for this ... but for those of whom who may not have the same issue, check the consent screen in ur google console tab, see if product name and email address are mentioned. It may also result in the same error.

于 2015-03-19T14:27:17.723 回答