• Register
0 votes

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();

I am struggling to find solution on it since yesterday.

8 4 2
2,300 points

Please log in or register to answer this question.

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 26 views
problem java.lang.illegalstateexception: already managing a googleapiclient with id 0
asked Feb 9 charles mathews 5.5k points
0 votes
1 answer 92 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 174 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 10 views
Problem: Getting this error > com.android.builder.testing.api.deviceexception: no connected devices!
asked Mar 19 Azlan2020 2.3k points
0 votes
1 answer 3 views
Problem: Hi I am facing this problem please help me with this.Thanks android connected to wifi but no internet
asked Mar 19 PkGuy 13.1k points
0 votes
1 answer 70 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 20 views
Problem: user does not have sufficient permissions for this profile.
asked Feb 17 Ethan ross 2.6k points
0 votes
1 answer 91 views
Problem: java.lang.IllegalStateException: Not allowed to start service Intent.
asked Feb 12 Shovo210 13.3k points
0 votes
1 answer 747 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, 2020 Raphael Pacheco 4.9k points