This problem occurred when I start my application on emulator Android 5.1.1 (x86_64) - API 22. I have read some discussions about it, but no one from them helped me.
I tried to adjust version of Google Play Services in gradle build script (I mean you should update the script with "app" name). Don't forget to sync gradle when you update something in your script.
My gradle script "app" after updates:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.itmm.map"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.android.gms:play-services:9.0.0'
testCompile 'junit:junit:4.12'
}
Please, have a look into dependencies section. You're interesting in the follwoing line of script:
compile 'com.google.android.gms:play-services:9.0.0'
Currently, ver. 9.0.0 helps me and everything is ok. I can see MapActivity on Android emulator. 9.0.0 is not a newest version of Google Play Services (the newest is 9.6.1), but it works and it can solve your problem, if you aren't interestion in new features of ver. 9.6.1.