I\'m kind of lost right now. I\'m implementing an Android application using Google maps.
In order to make it work I followed some tutorials which were pretty efficie
I encountered this same error trying to build on Android 7.0. I rebuilt under 6.0 and didn't have any issues. Reverting back 1 API level may help you as well.
To save yourself the trouble of configuring an emulator that does not have google play support,always use an emulator with the playicon
as depicted in the image:The play icon present under the Playstore row.
After installing the google play compatible emulator...run your app in the emulator again...and when you get the notification"App wont run unless......"click on the notification and follow the screen prompts:"Signing In using a gmail account...email and password etc",as soon as you agree to the google licence youl get the google play update screen:
update your google play and launch your app again. Also make sure you have the google dependencies in your app level gradle and gradle:
App level gradle build.gradle(Module:app)
dependencies {
}
apply plugin: 'com.google.gms.google-services'
Project level Gradle "build,gradle(Project:AppName)"
dependencies {
classpath 'com.google.gms:google-services:3.2.1'
}
I got this problem only when I am using android emulator from Android Studio. I solved the problem by adding google-services plugin to gradle:app
apply plugin: 'com.google.gms.google-services'
then on the dependencies add
compile 'com.google.android.gms:play-services:9.0.0'
previously I was using
compile 'com.google.android.gms:play-services:9.4.0'
but it gives error that there is a version mismatch and it suggest to use com.android.gms version 9.0.0
While the provided answers will work for an emulator, this could be a real issue on a real device and these solutions will not work on a real device. This could happen on an old device that has an outdated version of Google Play Services.
To overcome this issue, the Google Play Services library has a set of APIs to check the availability of Google Play Services, mainly the GoogleApiAvailability class provides a few methods to handle availability issues such as an outdated version.
Now, to detect whether a device has Google Play Services available or not, what I normally do is create a helper method to run the check
private boolean checkPlayServices(){
GoogleApiAvailability gaa = GoogleApiAvailability.getInstance();
int result = gaa.isGooglePlayServicesAvailable(getApplicationContext());
if(result != ConnectionResult.SUCCESS){
if(gaa.isUserResolvableError(result)){
gaa.getErrorDialog(this,result, REQUEST_PLAY_SERVICES_RESOLUTION).show();
}
return false;
}
return true;
}
This helper method checks whether Google Play Services is available or not by inspecting the error code returned from isGooglePlayServicesAvailable
. Then it calls isUserResolvableError
to determine if the error is resolvable by the user (e.g. by updating Google Play Services). If it is resolvable, then a dialog is displayed for the user to confirm he wants the system to resolve the error. Then call it on the Activity's onCreate
method, I run that check as below
//I normally assume Google Play services is available
private boolean playServicesAvailable = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_selector);
//check for rare case where Google Play Services is not available
playServicesAvailable = checkPlayServices();
if(!playServicesAvailable){
//hide UI elements and turn off features that rely on Google Play Services
}
}
Hope it helps some out there
In Android Studio 3, go to Tools -> SDK Manager
and install Google Play services
In the Android SDK Manager, you must install "Google APIs (x86 System Image)" under "Android 4.4.2 (API 19)". Quit Eclipse and restart it.
Then create a new android virtual device in AVD manager and choose "Google APIs x86 (Google Inc.) - API Level 19" as target. Check "Use Host GPU" to ensure the drawing of the map will be accelerated.
That's it, this new emulator will have Play Services preinstalled and it will run faster because it's a x86 image.