2

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..

Community
  • 1
  • 1
Wongeun Cho
  • 101
  • 2
  • 10

3 Answers3

3

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

enter image description here

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. enter image description here 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

  • Use a downgraded version of the Play Services library in you app (be carefull with this because if you used some new APIs your app will not compile)
MatPag
  • 41,742
  • 14
  • 105
  • 114
  • Where can I save this file? – Wongeun Cho Jun 10 '17 at 09:40
  • If you are downloading the Google Play Services apk from apkmirror, save the file in a folder, then drag the file on the running emulator, it will try to install the update and you will get an error message if something is not going ok (like signature mismatching and similar) – MatPag Jun 10 '17 at 09:41
  • Thank you! But I got,,the error message that, "The APK failed to install. Error : INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES" – Wongeun Cho Jun 10 '17 at 09:43
  • Ok that's a signature mismatch, which version you tried to install? – MatPag Jun 10 '17 at 09:44
  • I downloaded 10.0.84 (070-137749526) this version! http://www.apkmirror.com/apk/google-inc/google-play-services/google-play-services-10-0-84-release/google-play-services-10-0-84-070-137749526-android-apk-download/ – Wongeun Cho Jun 10 '17 at 09:50
  • Ok, wait a second i will updated my answer with images, so you can download the correct version without wasting time ;) (i'm searching an easy solution to this) – MatPag Jun 10 '17 at 09:51
  • And my AVD emulator's google play services version is 9.2.56 – Wongeun Cho Jun 10 '17 at 09:51
  • I appreciate it. I will wait for your answer – Wongeun Cho Jun 10 '17 at 09:52
  • Answer updated, check again the instructions and let me know if it works for you – MatPag Jun 10 '17 at 10:26
  • I appreciate your answer!! – Wongeun Cho Jun 10 '17 at 14:33
  • Firstly, I want to say "Thank you for caring my problem! your answer is so helpful for improving my android skill." However, after I installed the ADK, I got still same error message like, "The application won't run without google play services." even if I checked the new version google play service was installed..TT – Wongeun Cho Jun 10 '17 at 15:04
  • Can you find the Google Play Services app in the Apps? Where are you getting the error? – MatPag Jun 10 '17 at 15:35
  • Try to download and install [this](http://www.androidapksfree.com/apk/google-play-store-apk-latest-version-download/) in the emulator, it's the APK image of the PlayStore. After installing it, open your application, maybe it will show "Google Play Services updating" and some repetitive error will appear, click OK and wait a bit. Then close the app from background and open it again and it should works (more or less), maybe sometimes you will get some random "Google play services has stopped" error but should be ok – MatPag Jun 11 '17 at 06:20
  • Thank you!! I think it works but the screen only displays 'Google' on the bottom of left side of screen..not map.. However, you solve my connect Google Play Services problem!! I really appreciate it!!! Thank you!! – Wongeun Cho Jun 11 '17 at 07:07
  • Are you sure you added the API_KEY correctly? This happen if the API_KEY is absent or misconfigured ;) – MatPag Jun 11 '17 at 07:19
  • I solved everything thanks to you!! You save me! Is there any other thumb up button on your profile? – Wongeun Cho Jun 11 '17 at 07:23
  • You can simply press the button up on this answer and will be ok ^^. Good luck with everything. PS: I will update the answer with the latest details posted by me in the in comments when i have time ;) – MatPag Jun 11 '17 at 07:24
  • Because my reputation is less than 15, I can't press the button up TT – Wongeun Cho Jun 11 '17 at 08:10
  • Ahaha don't worry ;) – MatPag Jun 11 '17 at 09:37
2

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.

  1. Create a new virtual device by selecting Create Virtual Device(left-bottom corner) from Android Virtual Devices Manager.

  2. Select the Hardware 'Nexus 5x' or 'Nexus 5'.

  3. 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.

  4. Run your app again on the new virtual device and click on the 'Upgrade now ' option that shows along with the warning message.

  5. You will be directed to the Play Store and you can update you Google Play services easily.

    See your app runs smoothly!

Michel
  • 1,085
  • 13
  • 24
0

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.

Vivek
  • 566
  • 5
  • 6