So I am connecting to the google api client like this.
googleApiClient = new GoogleApiClient.Builder(context)
.addApi(LocationServices.API)
.addApi(ActivityRecognition.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
googleApiClient.connect();
This exact same code I am using in several places and it works well. It's not different from what you see in their tutorials. But now:
java.lang.IncompatibleClassChangeError: The method 'void com.google.android.gms.common.api.GoogleApiClient.connect()' was expected to be of type interface but instead was found to be of type virtual (declaration of 'java.lang.reflect.ArtMethod' appears in /system/framework/core-libart.jar)
The line that the stacktrace reports is:
googleApiClient.connect();
Using play services 8.1
compile 'com.google.android.gms:play-services:8.1.0'
Has anyone this this?
Your GoogleApiClient instance will automatically connect after your activity calls onStart() and disconnect after calling onStop(). Your app can immediately begin making read requests to Google APIs after building GoogleApiClient, without waiting for the connection to complete.
If a required authenticated API fails to connect, the entire GoogleApiClient will fail to connect and a failed ConnectionResult will be delivered to OnConnectionFailedListener#onConnectionFailed. Once a connection has successfully completed the only way to disconnect the authenticated APIs is to call disconnect () on this GoogleApiClient.
The GoogleApiClient.Builderclass provides methods that allow you to specify the Google APIs you want to use and your desired OAuth 2.0 scopes. Here is a code example that creates a GoogleApiClientinstance that connects with the Google Drive service:
Couldn't connect to Google API client: ConnectionResult {statusCode=API_UNAVAILABLE, resolution=null} because Google Places API for Android was not enabled in the API Console. @Elenasys : i am also getting same issue in production and build its works fine in development. Thanks in advance. I had a similar issue here.
The problem comes from one of the libraries your app depends on, library that depends itself on Google Play Services as well.
That library is using an older version of the Google Play Services SDK and it still relies on the fact that GoogleApiClient class is an interface. This has changed in 8.1.0 where it became an abstract class. This breaks backward compatibility because of the transitive dependencies of libraries.
Look if that library you use has a new updated version with 8.1.0 as well, or remove that dependency if possible.
More explanation can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With