clueless why app is get force closed on GoogleApiClient.connect()

我怕爱的太早我们不能终老 提交于 2019-12-13 02:50:26

问题


the app force closes on calling GoogleApiClient.connect() method, atleast if it doesn't connect it should call onConnectionFailed, but dont know why my app is getting force closed. when i comment GoogleApiClient.connect() method it doesn't force close........ trying from hours together .

this is my code

  package com.playservices.murali.playservices;

  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.Menu;
  import android.view.MenuItem;

   import com.google.android.gms.common.ConnectionResult;
   import com.google.android.gms.common.api.GoogleApiClient;
  import com.google.android.gms.games.Games;
  import com.google.android.gms.plus.Plus;


  public class MainActivity extends ActionBarActivity implements
    GoogleApiClient.ConnectionCallbacks,
    GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Games.API).addScope(Games.SCOPE_GAMES)
            .addApi(Plus.API).addScope(Plus.SCOPE_PLUS_LOGIN)
            .build();
}

@Override
protected void onStart()
{
    super.onStart();
    mGoogleApiClient.connect();
}

protected void onStop()
{
    super.onStop();
    //mGoogleApiClient.disconnect();
}
@Override
public void onConnected(Bundle bundle) {

}

@Override
public void onConnectionSuspended(int i) {

}

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {

}
}

the error message log for the android is below image


回答1:


There are a few common sources of this error:

  1. Do you have your Play Games App ID properly defined in your AndroidManifest.xml? It should look like this:

In your application tag:

<meta-data android:name="com.google.android.gms.games.APP_ID"
          android:value="@string/app_id" />
  1. In the Google Play Developers console, have you added all of the correct accounts in the Testers tab? Any Google account that wants to use your application before it is published must be registered here.

  2. Have you (properly) created a Client ID for your application? For Games make sure to do this in the Google Play Developer Console through the Linked Apps tab and not the Google Developer Console.



来源:https://stackoverflow.com/questions/28314978/clueless-why-app-is-get-force-closed-on-googleapiclient-connect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!