Reputation: 111
I am struggling to make an android app now. I have some problem.
As I wrote in title, I got a problem about getting google map in my AVD.
To fix this problem, I googled a lot of solutions and applied it. However, I didn't got the solution yet.
Here is my Gradle Source code.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "org.androidtown.myapplication"
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
//with non-zero exit value
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile 'com.android.support:recyclerview-v7:25.1.0'
compile 'com.google.android.gms:play-services:10.0.1'
compile 'com.google.android.gms:play-services-maps:10.0.1'
compile 'com.google.android.gms:play-services-location:10.0.1'
compile 'com.android.support:multidex:1.0.1'
testCompile 'junit:junit:4.12'
}
And this is my screen Error screen in AVD And this picture is about my SDK tools enter image description here
Lastly, this is my manifests code.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.androidtown.myapplication">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".NightWorWorkSpace.addPost">
<intent-filter>
<action android:name="org.androidtown.myapplication.NightWorWorkSpace.ADD_POST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".NightWorWorkSpace.CompanyList">
<intent-filter>
<action android:name="org.androidtown.myapplication.NightWorWorkSpace.COMPANY_LIST" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="My API KEY!!" />
<activity
android:name=".NightWorWorkSpace.NightMap"
android:label="@string/title_activity_night_map">
<intent-filter>
<action android:name="org.androidtown.myapplication.NightWorWorkSpace.NIGHT_MAP" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
And I am using API 18 (4.3 Jelly Beans)
How could I fix this problem? I spend my time on it for two days..
Upvotes: 2
Views: 7248
Reputation: 599
In my case the emulator was showing "Update google play services" but there was no play services app in the emulator. So the solution was the image I was using in the emulator was not updated one. So I deleted the emulator and created new one and the app worked fine.
Upvotes: 0
Reputation: 1153
Running the app on a virtual device with system image, 'Google Play API' instead of 'Google API' will solve your issue smoothly..
Virtual devices Nexus 5x and Nexus 5 supports 'Google Play API' image.
Google Play API comes with Nougat 7.1.1 and O 8.0.
Just follow the below simple steps and make sure your pc is connected to internet.
Create a new virtual device by selecting Create Virtual Device(left-bottom corner) from Android Virtual Devices Manager.
Select the Hardware 'Nexus 5x' or 'Nexus 5'.
Download the system image 'Nougat' with Google Play or 'O' with Google Play. 'O' is the latest Android 8.0 version.
4.Click on Next and Finish.
Run your app again on the new virtual device and click on the 'Upgrade now ' option that shows along with the warning message.
You will be directed to the Play Store and you can update you Google Play services easily.
See your app runs smoothly!
Upvotes: 2
Reputation: 44907
This happen everytime you have a mismatch between the version of Google Play Services installed in your device (or image), with the ones requested by the Play Services libraries you are using.
The first thing to do is to be sure that the image you are using is updated to the last version.
The second thing is to know which version is currently installed in the image. You can found it going in Settings->Apps->Google Play Services and you can find the version like in the example image below
Then when you know which version is installed, you could try to:
Update the Play Services with newer packages you can find online here. To use this technique you need to follow this small guide:
Step 1 Create a new AVD with an API image which doesn't contain the Google APIs.
This is the key of everything, in this way you can't obtain INSTALL_FAILED_UPDATE_INCOMPATIBLE because there are no GPS already installed in your emulator :D). In your case, for API 18, you need to download the Android image indicated with the red arrow below.
Then finish to setup the AVD.
Step 2 You need to know which version of the Google Play Services to download. You said in the emulator with Google API there is 9.2.56 version, which doesn't work with your 10.0.1 libraries in your app. So let's install GPS with at least version 10.2.91 from ApkMirror, i selected the version with ABI x86
(because you downloaded the x86 version) and with Density nodpi
(so you can be sure that it will work on every screen size). Click here to download the APK
Step 3 Launch the AVD configured in Step 1 and drag the downloaded GPS apk on top of it. It should install the Google Play Services without problems. Run your app and see if it works.
Use a real phone (if you have access to a real phone :D) where Play Services can be updated easier from Play Store
Upvotes: 3