• Register
0 votes
31 views

Problem :

Now a days I am learning Android Programming. I am facing below error message while trying to implement the logout functionality for the Google Sign-In for the Android:

“Caused by: java.lang.IllegalStateException: GoogleApiClient is not connected yet.”

The crash always occurs in my Java file where I am trying to call the signOut() method.

Below is my java code causing error

private void mygoogleSignOut(){
    myGoogleApiClient = App.getInstance().getClient();
    Auth.GoogleSignInApi.signOut(myGoogleApiClient);
}

I am struggling to find solution on it since yesterday.

8 4 2
2,300 points

1 Answer

0 votes

Solution :

I know you are learning Android Programming. You can try below solution to fix the error.

I can tell you the actual cause of your error is not at the object creation but it is present at more than one place it is usually found at "enableAutoManage" invocation while Building your Client object.

I have found the required API doc.  it clearly suggests that it will automatically do a life cycle management just by calling the methods on the onStart & onStop methods of your activity.

So if you are planning to use the same object across all the activities then you must avoid calling the "enableAutoManage" and invoke your apiObject.connect(use in onStart of activity) and the apiObject.disconnect() (use in onStop of activity).

This worked for me so I am very sure that it will work for you too.

5 2 1
4,980 points

Related questions

0 votes
1 answer 67 views
67 views
Problem : While executing Android code getting below error java.lang.illegalstateexception could not execute method of the activity
asked Oct 23, 2019 peterlaw 6.9k points
0 votes
1 answer 96 views
96 views
Problem : I am getting bellow error while learning android and trying to make a semi-useful app. java.lang.illegalstateexception: could not execute method for android:onclick
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 50 views
50 views
Problem : I am getting bellow error while I'm trying to setup an Android dev environment on Mac error:buildtools 24.0.2 requires java 1.8 or above. current jdk version is 1.7.
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 27 views
27 views
Problem: Currently I am trying to learn Android programming. I am also trying to make an android studio project and I am learning to debug my Android application. While running my application everything works perfectly fine, but if I try to debug it then I face below error: “Could not connect to remote process. Aborting debug session.” How can I fix this Android issue?
asked Sep 1 Raphael Pacheco 4.9k points