microg/GmsCore · error · IllegalStateException
Not connected!
Error message
Not connected!
What it means
AbstractPlayServicesClient.assertConnected() throws IllegalStateException when the underlying GoogleApiClient is not currently connected. Many client API methods call assertConnected() first, so invoking an API operation before the connection is established (or after it dropped) fails with 'Not connected!'.
Source
Thrown at play-services-base/src/main/java/org/microg/gms/common/api/AbstractPlayServicesClient.java:37
import android.util.Log;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.api.GoogleApiClient;
import org.microg.gms.common.ForwardConnectionCallbacks;
import org.microg.gms.common.ForwardConnectionFailedListener;
public class AbstractPlayServicesClient implements GooglePlayServicesClient {
private static final String TAG = "GmsPlayServicesClient";
protected final GoogleApiClient googleApiClient;
public AbstractPlayServicesClient(GoogleApiClient googleApiClient) {
this.googleApiClient = googleApiClient;
}
public void assertConnected() {
if (!isConnected()) throw new IllegalStateException("Not connected!");
}
@Override
public void connect() {
Log.d(TAG, "connect()");
googleApiClient.connect();
}
@Override
public void disconnect() {
Log.d(TAG, "disconnect()");
//TODO googleApiClient.disconnect();
}
@Override
public boolean isConnected() {
return googleApiClient.isConnected();
}View on GitHub (pinned to 157c9d86ac)
Solutions
- Wait for onConnected(Bundle) callback before calling any API methods
- Check isConnected() before invoking operations
- Implement ConnectionCallbacks and ConnectionFailedListener and retry connect() on failure
- Use GoogleApiClient with await()/blocking connect in background threads
Example fix
// before
client.doSomething(); // called in onStart, not yet connected
// after
@Override public void onConnected(Bundle hint) { client.doSomething(); }
// or: if (client.isConnected()) client.doSomething(); Defensive patterns
Strategy: validation
Validate before calling
if (client.isConnected()) {
client.doSomething();
} else {
client.connect(); // wait for onConnected
} Try / catch
try { client.doSomething(); } catch (IllegalStateException e) { client.connect(); /* retry after onConnected */ } Prevention
- Only call API methods inside onConnected()
- Implement onConnectionSuspended/onConnectionFailed handlers
- Check isConnected() defensively before each call
When it happens
Trigger: Calling a client API method (e.g. on a Plus/Drive-style client) before GoogleApiClient.connect() completes its CONNECTION_SUSPENDED->CONNECTED cycle, or after onConnectionSuspended/onConnectionFailed.
Common situations: Calling API methods in onCreate/onStart before the async connect() succeeds; not handling onConnectionFailed; calling methods after the client was disconnected in onStop.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Position already set using positionFromBounds()
- Position already set using position()
- App already listening
- Nothing cached: $cacheKey
AI-assisted analysis of microg/GmsCore@157c9d86ac (2026-09-06).
Data as JSON: /api/errors/1b6e93dfb1228f96.
Report an issue: GitHub.