Reputation: 904
I'm getting an error in Android Studio for the following:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();
I have put this in my manifest,
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
and compile 'com.google.android.gms:play-services:6.5.87'
in my gradle dependencies.
I've downloaded the required sdk files as well.
Why do I still get this error?
Upvotes: 23
Views: 58446
Reputation: 234
the question is old ,but now that GoogleApiClient is deprecated I found out that I can't use it anymore and that one should use its substitute, subclasses of GoogleApi .
Upvotes: 0
Reputation: 77
Add following lines to your dependencies to use Google Places Api interfaces
dependecies{compile 'com.google.android.gms:play-services:11.2.0'
testCompile 'junit:junit:4.12'
}
Upvotes: 1
Reputation: 11
I had this problem, only with import com.google.android.gms.common.api.GoogleApiClient
;I unfortunately had moved <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" />
after its relative activity <activity android:name=".MapsActivity" android:label="@string/title_activity_maps" ></activity>
. I returned to previous state and the problem was solved.
Upvotes: 1
Reputation: 559
Just to log the problem.
This happens when there is version conflict. Check the build message, and it will suggest the version you should be importing.
The classpath version in main gradle (classpath 'com.google.gms:google-services:3.1.0'
) should be complaint with the version of jar included in the app gradle (compile 'com.google.android.gms:play-services-auth:11.0.0'
)
Upvotes: 0
Reputation: 390
I had to do the following to get my app to compile successfully:
'com.google.android.gms:play-services:<version>'
Add imports as needed:
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
In Android Studio: File --> Invalidate/Restart...
Clean build
Upvotes: 6
Reputation: 16946
For the benefit of searchers:
If you are following the android tutorial that relates to this, you can add the dependency via the UI.
Upvotes: 41
Reputation: 904
Even though not officially listed in the tutorial, you must use the following imports:
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
Upvotes: 16