代码之家  ›  专栏  ›  技术社区  ›  Rawr

GoogleApiClient。connect()导致强制关闭

  •  2
  • Rawr  · 技术社区  · 9 年前

    首先,我发现这个问题以前被问过两次,但他们都没有标记答案或解决问题的答案。

    这是我第一次实施 Google Sign-In 但是 GoogleApiClient.connect(); 导致施加力关闭。我不知道为什么。知道吗?谢谢

    代码:

    package com.example.fujitsu.myapplication;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    
    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.example.games.basegameutils.BaseGameUtils;
    
    public class MainActivity extends Activity implements 
            View.OnClickListener,
            GoogleApiClient.ConnectionCallbacks,
            GoogleApiClient.OnConnectionFailedListener {
    
    private GoogleApiClient mGoogleApiClient;
    private static int RC_SIGN_IN = 9001;
    
    private boolean mResolvingConnectionFailure = false;
    private boolean mAutoStartSignInFlow = true;
    private boolean mSignInClicked = false;
    boolean mExplicitSignOut = false;
    boolean mInSignInFlow = false; 
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        // Create the Google Api Client with access to the Play Games services
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(Games.API).addScope(Games.SCOPE_GAMES)
                .build();
        findViewById(R.id.sign_in_button).setOnClickListener(this);
        findViewById(R.id.sign_out_button).setOnClickListener(this);
    
    }
    
    @Override
    protected void onStart() {
        super.onStart();
        if (!mInSignInFlow && !mExplicitSignOut) {
            // auto sign in
            mGoogleApiClient.connect();
        }
    }
    
    @Override
    protected void onStop() {
        super.onStop();
        mGoogleApiClient.disconnect();
    }
    
    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.sign_in_button) {
            // start the asynchronous sign in flow
            mSignInClicked = true;
            mGoogleApiClient.connect();
        }
        else if (view.getId() == R.id.sign_out_button) {
    
            // sign out.
            mSignInClicked = false;
            // user explicitly signed out, so turn off auto sign in
            mExplicitSignOut = true;
            if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
                Games.signOut(mGoogleApiClient);
                mGoogleApiClient.disconnect();
            }
    
            // show sign-in button, hide the sign-out button
            findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
            findViewById(R.id.sign_out_button).setVisibility(View.GONE);
        }
    }
    
    @Override
    public void onConnected(Bundle connectionHint) {
        // show sign-out button, hide the sign-in button
        findViewById(R.id.sign_in_button).setVisibility(View.GONE);
        findViewById(R.id.sign_out_button).setVisibility(View.VISIBLE);
    
    }
    
    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        if (mResolvingConnectionFailure) {
            // already resolving
            return;
        }
    
        // if the sign-in button was clicked or if auto sign-in is enabled,
        // launch the sign-in flow
        if (mSignInClicked || mAutoStartSignInFlow) {
            mAutoStartSignInFlow = false;
            mSignInClicked = false;
            mResolvingConnectionFailure = true;
    
            if (!BaseGameUtils.resolveConnectionFailure(this,
                    mGoogleApiClient, connectionResult,
                    RC_SIGN_IN, "There was an issue with sign-in, please try again later.")) {
                mResolvingConnectionFailure = false;
            }
        }
    
    }
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent intent) {
        if (requestCode == RC_SIGN_IN) {
            mSignInClicked = false;
            mResolvingConnectionFailure = false;
            if (resultCode == RESULT_OK) {
                mGoogleApiClient.connect();
            } else {
                BaseGameUtils.showActivityResultError(this,
                        requestCode, resultCode, R.string.signin_failure);
            }
        }
    }
    
    
    @Override
    public void onConnectionSuspended(int i) {
        // Attempt to reconnect
        mGoogleApiClient.connect();
    }
    }
    

    Android清单文件:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.fujitsu.myapplication" >
    
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
    
        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    
    </manifest>
    

    日志目录:

    libcore.io.ErrnoException: close failed: EBADF (Bad file number)
                at libcore.io.Posix.close(Native Method)
                at libcore.io.BlockGuardOs.close(BlockGuardOs.java:75)
                at com.android.internal.os.ZygoteInit.closeServerSocket(ZygoteInit.java:221)
                at com.android.internal.os.ZygoteConnection.handleChildProc(ZygoteConnection.java:879)
                at com.android.internal.os.ZygoteConnection.runOnce(ZygoteConnection.java:242)
                at com.android.internal.os.ZygoteInit.runSelectLoop(ZygoteInit.java:713)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:649)
                at dalvik.system.NativeStart.main(Native Method)
    08-11 14:08:46.883  24869-24881/com.example.fujitsu.myapplication D/dalvikvm﹕ threadid=9: interp stack at 0x5f551000
    08-11 14:08:46.883  24869-24881/com.example.fujitsu.myapplication D/dalvikvm﹕ init ref table
    08-11 14:08:46.883  24869-24881/com.example.fujitsu.myapplication D/dalvikvm﹕ init mutex
    08-11 14:08:46.884  24869-24882/com.example.fujitsu.myapplication D/dalvikvm﹕ threadid=10: interp stack at 0x5f66f000
    08-11 14:08:46.884  24869-24882/com.example.fujitsu.myapplication D/dalvikvm﹕ init ref table
    08-11 14:08:46.884  24869-24882/com.example.fujitsu.myapplication D/dalvikvm﹕ init mutex
    08-11 14:08:46.929  24869-24869/com.example.fujitsu.myapplication V/SettingsProviderInterface﹕ invalidate [system]: current 59 != cached 0
    08-11 14:08:46.931  24869-24869/com.example.fujitsu.myapplication D/ActivityThread﹕ hoder:android.app.IActivityManager$ContentProviderHolder@4266d840,provider,holder.Provider:android.content.ContentProviderProxy@4266dfb8
    08-11 14:08:46.934  24869-24869/com.example.fujitsu.myapplication D/asset﹕ AssetManager-->addDefaultAssets CIP path not exsit!
    08-11 14:08:46.960  24869-24869/com.example.fujitsu.myapplication D/Proxy﹕ setHttpRequestCheckHandler
    08-11 14:08:46.961  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ open_cached_dex_file : /data/app/com.example.fujitsu.myapplication-1.apk /data/dalvik-cache/data@app@com.example.fujitsu.myapplication-1.apk@classes.dex
    08-11 14:08:46.970  24869-24869/com.example.fujitsu.myapplication D/ActivityThread﹕ BIND_APPLICATION handled : 0 / AppBindData{appInfo=ApplicationInfo{4266ace8 com.example.fujitsu.myapplication}}
    08-11 14:08:46.971  24869-24869/com.example.fujitsu.myapplication V/ActivityThread﹕ Handling launch of ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}}
    08-11 14:08:47.021  24869-24869/com.example.fujitsu.myapplication V/ActivityThread﹕ ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}}: app=android.app.Application@42672248, appName=com.example.fujitsu.myapplication, pkg=com.example.fujitsu.myapplication, comp={com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}, dir=/data/app/com.example.fujitsu.myapplication-1.apk
    08-11 14:08:47.025  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ create interp thread : stack size=128KB
    08-11 14:08:47.025  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ create new thread
    08-11 14:08:47.025  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ new thread created
    08-11 14:08:47.025  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ update thread list
    08-11 14:08:47.025  24869-24886/com.example.fujitsu.myapplication D/dalvikvm﹕ threadid=11: interp stack at 0x5fd9e000
    08-11 14:08:47.025  24869-24886/com.example.fujitsu.myapplication D/dalvikvm﹕ init ref table
    08-11 14:08:47.025  24869-24886/com.example.fujitsu.myapplication D/dalvikvm﹕ init mutex
    08-11 14:08:47.025  24869-24886/com.example.fujitsu.myapplication D/dalvikvm﹕ threadid=11: created from interp
    08-11 14:08:47.025  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ start new thread
    08-11 14:08:47.025  24869-24886/com.example.fujitsu.myapplication D/dalvikvm﹕ threadid=11: notify debugger
    08-11 14:08:47.025  24869-24886/com.example.fujitsu.myapplication D/dalvikvm﹕ threadid=11 (LaunchIconThemeResource): calling run()
    08-11 14:08:47.033  24869-24869/com.example.fujitsu.myapplication D/asset﹕ AssetManager-->addDefaultAssets CIP path not exsit!
    08-11 14:08:47.062  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.example.fujitsu.myapplication asetfile:null
    08-11 14:08:47.063  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.example.fujitsu.myapplication asetfile:null
    08-11 14:08:47.128  24869-24869/com.example.fujitsu.myapplication I/dalvikvm﹕ Could not find method android.app.Notification$Builder.setLocalOnly, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zza
    08-11 14:08:47.128  24869-24869/com.example.fujitsu.myapplication W/dalvikvm﹕ VFY: unable to resolve virtual method 245: Landroid/app/Notification$Builder;.setLocalOnly (Z)Landroid/app/Notification$Builder;
    08-11 14:08:47.128  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x00c2
    08-11 14:08:47.130  24869-24869/com.example.fujitsu.myapplication I/dalvikvm﹕ Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzh
    08-11 14:08:47.130  24869-24869/com.example.fujitsu.myapplication W/dalvikvm﹕ VFY: unable to resolve virtual method 535: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller;
    08-11 14:08:47.130  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000b
    08-11 14:08:47.131  24869-24869/com.example.fujitsu.myapplication D/asset﹕ AssetManager-->addDefaultAssets CIP path not exsit!
    08-11 14:08:47.193  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ open_cached_dex_file : /system/framework/com.android.location.provider.jar /data/dalvik-cache/system@framework@com.android.location.provider.jar@classes.dex
    08-11 14:08:47.194  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ open_cached_dex_file : /system/framework/com.android.media.remotedisplay.jar /data/dalvik-cache/system@framework@com.android.media.remotedisplay.jar@classes.dex
    08-11 14:08:47.197  24869-24869/com.example.fujitsu.myapplication D/dalvikvm﹕ open_cached_dex_file : /data/app/com.google.android.gms-1.apk /data/dalvik-cache/data@app@com.google.android.gms-1.apk@classes.dex
    08-11 14:08:47.227  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.example.fujitsu.myapplication asetfile:null
    08-11 14:08:47.243  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.google.android.gms asetfile:null
    08-11 14:08:47.253  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.google.android.gms asetfile:null
    08-11 14:08:47.259  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.google.android.gms asetfile:null
    08-11 14:08:47.262  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.google.android.gms asetfile:null
    08-11 14:08:47.264  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.google.android.gms asetfile:null
    08-11 14:08:47.268  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.google.android.gms asetfile:null
    08-11 14:08:47.281  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ LaunchIconThemeResourcegetDrawable packageName:com.example.fujitsu.myapplication asetfile:null
    08-11 14:08:47.316  24869-24869/com.example.fujitsu.myapplication 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
    08-11 14:08:47.317  24869-24869/com.example.fujitsu.myapplication V/ActivityThread﹕ Performing resume of ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}} finished=false
    08-11 14:08:47.317  24869-24869/com.example.fujitsu.myapplication D/ActivityThread﹕ ACT-AM_ON_RESUME_CALLED ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}}
    08-11 14:08:47.317  24869-24869/com.example.fujitsu.myapplication V/ActivityThread﹕ Resume ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}} started activity: false, hideForNow: false, finished: false
    08-11 14:08:47.317  24869-24869/com.example.fujitsu.myapplication V/PhoneWindow﹕ DecorView setVisiblity: visibility = 4 ,Parent =null, this =com.android.internal.policy.impl.PhoneWindow$DecorView{4267a318 I.E..... R.....ID 0,0-0,0}
    08-11 14:08:47.326  24869-24869/com.example.fujitsu.myapplication V/ActivityThread﹕ Resuming ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}} with isForward=true
    08-11 14:08:47.326  24869-24869/com.example.fujitsu.myapplication V/PhoneWindow﹕ DecorView setVisiblity: visibility = 0 ,Parent =ViewRoot{4271dc00 com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity,ident = 0}, this =com.android.internal.policy.impl.PhoneWindow$DecorView{4267a318 V.E..... R.....ID 0,0-0,0}
    08-11 14:08:47.326  24869-24869/com.example.fujitsu.myapplication V/ActivityThread﹕ Scheduling idle handler for ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}}
    08-11 14:08:47.327  24869-24869/com.example.fujitsu.myapplication D/ActivityThread﹕ ACT-LAUNCH_ACTIVITY handled : 0 / ActivityRecord{4266c7a8 token=android.os.BinderProxy@4266bd30 {com.example.fujitsu.myapplication/com.example.fujitsu.myapplication.MainActivity}}
    08-11 14:08:47.338  24869-24869/com.example.fujitsu.myapplication D/jiayh2﹕ FontThemeManager createThemeFont typefacetype=2, curfontpath=/system/fonts/DroidSansFallback.ttf
    08-11 14:08:47.404  24869-24869/com.example.fujitsu.myapplication D/GraphicBuffer﹕ create handle(0x622ea9b0) (w:736, h:1280, f:1)
    08-11 14:08:47.407  24869-24869/com.example.fujitsu.myapplication D/OpenGLRenderer﹕ Enabling debug mode 0
    08-11 14:08:47.408  24869-24869/com.example.fujitsu.myapplication D/GraphicBuffer﹕ create handle(0x626ad790) (w:1984, h:1472, f:1)
    08-11 14:08:47.417  24869-24869/com.example.fujitsu.myapplication D/OpenGLRenderer﹕ setViewport 720x1280 <0x622eaad8>
    08-11 14:08:47.418  24869-24869/com.example.fujitsu.myapplication V/InputMethodManager﹕ onWindowFocus: null softInputMode=288 first=true flags=#1810100
    08-11 14:08:47.418  24869-24869/com.example.fujitsu.myapplication V/InputMethodManager﹕ START INPUT: com.android.internal.policy.impl.PhoneWindow$DecorView{4267a318 V.E..... R.....ID 0,0-720,1280} ic=null tba=android.view.inputmethod.EditorInfo@4272b720 controlFlags=#104
    08-11 14:08:47.423  24869-24889/com.example.fujitsu.myapplication D/dalvikvm﹕ threadid=12: interp stack at 0x63306000
    08-11 14:08:47.423  24869-24889/com.example.fujitsu.myapplication D/dalvikvm﹕ init ref table
    08-11 14:08:47.423  24869-24889/com.example.fujitsu.myapplication D/dalvikvm﹕ init mutex
    08-11 14:08:49.603  24869-24869/com.example.fujitsu.myapplication I/View﹕ Touch down dispatch to android.widget.RelativeLayout{4267ffc0 V.E..... ......I. 0,0-720,1230}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=150.79057, y[0]=143.84856, Xw[0]=32.0, Yw[0]=32.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=35442457, downTime=35442457, deviceId=3, source=0x1002 }
    08-11 14:08:49.603  24869-24869/com.example.fujitsu.myapplication I/View﹕ Touch down dispatch to android.widget.FrameLayout{4267ef40 V.ED.... ......I. 0,50-720,1280 #1020002 android:id/content}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=150.79057, y[0]=143.84856, Xw[0]=32.0, Yw[0]=32.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=35442457, downTime=35442457, deviceId=3, source=0x1002 }
    08-11 14:08:49.604  24869-24869/com.example.fujitsu.myapplication I/View﹕ Touch down dispatch to android.widget.LinearLayout{4267b400 V.E..... ......I. 0,0-720,1280}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=150.79057, y[0]=193.84856, Xw[0]=32.0, Yw[0]=32.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=35442457, downTime=35442457, deviceId=3, source=0x1002 }
    08-11 14:08:49.604  24869-24869/com.example.fujitsu.myapplication I/View﹕ Touch down dispatch to com.android.internal.policy.impl.PhoneWindow$DecorView{4267a318 V.E..... R.....I. 0,0-720,1280}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=150.79057, y[0]=193.84856, Xw[0]=32.0, Yw[0]=32.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=35442457, downTime=35442457, deviceId=3, source=0x1002 }
    08-11 14:08:49.715  24869-24869/com.example.fujitsu.myapplication I/View﹕ Touch up dispatch to com.android.internal.policy.impl.PhoneWindow$DecorView{4267a318 V.E..... R.....I. 0,0-720,1280}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=149.79196, y[0]=193.84856, Xw[0]=33.0, Yw[0]=33.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=35442570, downTime=35442457, deviceId=3, source=0x1002 }
    08-11 14:08:56.147  24869-24869/com.example.fujitsu.myapplication I/View﹕ Touch down dispatch to com.google.android.gms.common.internal.cq{42690b00 VFED..C. ........ 0,0-216,96}, event = MotionEvent { action=ACTION_DOWN, id[0]=0, x[0]=133.76978, y[0]=50.89618, Xw[0]=64.0, Yw[0]=64.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=35448999, downTime=35448999, deviceId=3, source=0x1002 }
    08-11 14:08:56.168  24869-24869/com.example.fujitsu.myapplication D/GraphicBuffer﹕ create handle(0x633c3b28) (w:736, h:1280, f:1)
    08-11 14:08:56.317  24869-24869/com.example.fujitsu.myapplication I/View﹕ Touch up dispatch to com.google.android.gms.common.internal.cq{42690b00 VFED..C. ...P.... 0,0-216,96}, event = MotionEvent { action=ACTION_UP, id[0]=0, x[0]=132.77115, y[0]=50.89618, Xw[0]=49.0, Yw[0]=49.0, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=35449172, downTime=35448999, deviceId=3, source=0x1002 }
    08-11 14:08:56.337  24869-24869/com.example.fujitsu.myapplication D/GraphicBuffer﹕ create handle(0x6332fc28) (w:736, h:1280, f:1)
    08-11 14:08:56.452  24869-24869/com.example.fujitsu.myapplication D/AndroidRuntime﹕ Shutting down VM
    08-11 14:08:56.452  24869-24869/com.example.fujitsu.myapplication W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x4190cc98)
    08-11 14:08:56.452  24869-24869/com.example.fujitsu.myapplication W/dalvikvm﹕ threadid=1: uncaught exception occurred
    08-11 14:08:56.452  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
    08-11 14:08:56.461  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at com.google.android.gms.common.internal.zzi$zza.zzc(Unknown Source)
    08-11 14:08:56.462  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at com.google.android.gms.common.internal.zzi$zza.zzr(Unknown Source)
    08-11 14:08:56.462  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at com.google.android.gms.common.internal.zzi$zzc.zznQ(Unknown Source)
    08-11 14:08:56.462  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at com.google.android.gms.common.internal.zzi$zzb.handleMessage(Unknown Source)
    08-11 14:08:56.462  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:110)
    08-11 14:08:56.463  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at android.os.Looper.loop(Looper.java:193)
    08-11 14:08:56.463  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5395)
    08-11 14:08:56.463  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
    08-11 14:08:56.463  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
    08-11 14:08:56.463  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:837)
    08-11 14:08:56.464  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
    08-11 14:08:56.464  24869-24869/com.example.fujitsu.myapplication W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
    08-11 14:08:56.464  24869-24869/com.example.fujitsu.myapplication W/dalvikvm﹕ threadid=1: calling UncaughtExceptionHandler
    08-11 14:08:56.465  24869-24869/com.example.fujitsu.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main
        Process: com.example.fujitsu.myapplication, PID: 24869
        java.lang.IllegalStateException: A fatal developer error has occurred. Check the logs for further information.
                at com.google.android.gms.common.internal.zzi$zza.zzc(Unknown Source)
                at com.google.android.gms.common.internal.zzi$zza.zzr(Unknown Source)
                at com.google.android.gms.common.internal.zzi$zzc.zznQ(Unknown Source)
                at com.google.android.gms.common.internal.zzi$zzb.handleMessage(Unknown Source)
                at android.os.Handler.dispatchMessage(Handler.java:110)
                at android.os.Looper.loop(Looper.java:193)
                at android.app.ActivityThread.main(ActivityThread.java:5395)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:515)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:837)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:653)
                at dalvik.system.NativeStart.main(Native Method)
    
    1 回复  |  直到 9 年前
        1
  •  0
  •   Jayaprakash    9 年前

    您可以按照以下步骤解决此问题, 步骤1:首先在开发人员控制台中启用google+API。从开发人员控制台创建新的客户端id。

    第二步:将GooglePlay服务添加到我们的项目中。

    步骤3:在清单中声明权限。

    步骤4:初始化应用程序的Google API客户端,

    首先通过拨打 checkPlayServices() 在里面 onResume()

    在设备上提供播放服务后,构建 GoogleApiClient 通过调用 buildGoogleApiClient() 方法

    通过调用 mGoogleApiClient.connect() 在里面 onStart() 方法通过调用此, onConnectionFailed() , onConnected() onConnectionSuspended() 将根据连接状态触发。

    一旦google API成功连接, //显示注销按钮,隐藏登录按钮

    findViewById(R.id.sign_in_button).setVisibility(View.GONE);
    findViewById(R.id.sign_out_button).setVisibility(View.VISIBLE);
    

    应该被召入 on连接() 方法

    如果你遇到理解困难,请跟随 https://developers.google.com/+/mobile/android/getting-started