0

I've seen this: Android Emulator: This app won't run without Google Play services

It seems similar but it didn't solve for my case. I have already imported the google play services project, and added to the libraries but it still gave me that error.

The solution for that link is to change to Google API for emulator but it's taking too long for the avd to start up and when I tried to run my application, it's taking very very long..

I want to display Google Maps so i following this Youtube video: https://www.youtube.com/watch?v=awX5T-EwLPc

I have already done the following to try make it work:

1) Import the google-play-services_lib project

2) Installed Google Play Services in SDK manager

3) Created API_KEY with correct SHA1

4) Emulator Target: Android 4.4.2 - API Level 19

5) Installed com.android.vending-5.0.37-80300037-minAPI9.apk when I run the application using cmd.

6) Installed a Google Play Store app in my emulator using the above method.

7) Added a reference to google-play-service_lib project at Project --> Properties --> Android --> Library --> (added the google-play-services_lib project)

8) Project Build Target: Standard Android platform 4.4.2

9) At Google Developer Console, I have enabled Google Maps Android API v2

MainActivity.java

package com.rachel.googlemaprouting;

public class MainActivity extends Activity {

private final LatLng LOCATION_SG = new LatLng(1.3499391,103.7492432);

private GoogleMap map;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

     map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        return true;
    }
    return super.onOptionsItemSelected(item);
}

public void onClick_Singapore(View v){
    map.setMapType(GoogleMap.MAP_TYPE_NORMAL);
    CameraUpdate update = CameraUpdateFactory.newLatLngZoom(LOCATION_SG, 9);
    map.animateCamera(update);
}
}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.rachel.googlemaprouting.MainActivity" >

<!--  <Button 
    android:id="@+id/btnSingapore"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:onClick="onClick_Singapore"
    android:text="Singapore" />-->

    <fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

 </RelativeLayout>

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.rachel.googlemaprouting"
    android:versionCode="1"
    android:versionName="1.0" >


    <uses-sdk
        android:minSdkVersion="15"
        android:targetSdkVersion="19" />

    <permission
        android:name="com.rachel.googlemaprouting.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
        <uses-permission    android:name="com.rachel.googlemaprouting.permission.MAPS_RECEIVE"/>

    <uses-permission android:name="android.permission.INTERNET"/>    
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <!-- The following two permissions are not required to use
         Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >


        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="[MY_API_KEY]"/> // i did fill this up with the api key i gotten.
        <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        </application>

    </manifest>

Can anyone please help me to find out what are the problems here? :/

  1. There are no errors in the LogCat.
  2. When the app appears, it shows the following: "MapRouting won't run without Google Play services, which are missing from your phone." [Get Google Play Services] - button.

  3. Console when I run the app.

    [2015-06-01 18:54:48 - MapRouting] ------------------------------
    [2015-06-01 18:54:48 - MapRouting] Android Launch!
    [2015-06-01 18:54:48 - MapRouting] adb is running normally.
    [2015-06-01 18:54:48 - MapRouting] Performing com.rachel.googlemaprouting.MainActivity activity launch
    [2015-06-01 18:54:48 - MapRouting] Automatic Target Mode: using existing emulator 'emulator-5556' running compatible AVD 'myAVD'
    [2015-06-01 18:54:48 - MapRouting] Uploading MapRouting.apk onto device 'emulator-5556'
    [2015-06-01 18:54:51 - MapRouting] Installing MapRouting.apk...
    [2015-06-01 18:55:14 - MapRouting] Success!
    [2015-06-01 18:55:14 - MapRouting] Starting activity com.rachel.googlemaprouting.MainActivity on device emulator-5556
    [2015-06-01 18:55:17 - MapRouting] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.rachel.googlemaprouting/.MainActivity }
    

This app won't run without Google Play Services, which are missing from your phone

In this link they say that we can't view map on emulator, but in the Youtube video, the youtuber is able to..

Please help...

Community
  • 1
  • 1
Taeyeon.
  • 49
  • 1
  • 3
  • 10

1 Answers1

2

As you may already notices, the google maps in your app needs the phones to have google play services installed. And I think in your case, your emulator does not have google play services.

You used to have to install that separately by hand onto the emulator, but Google have it officially supported after 4.4.2.

All you need to do now is to download and set your Emulator Target: to Google APIs (Google Inc.) - API Level 19 rather than Android 4.4.2 - API Level 19.

Note that the emulator is slow and for the first time you run your app, it may takes minutes before it start rendering your map. (you would see a grey screen with the map controllers)

Even the emulator works, it is always the best to test your app on a real devices, specially when you are using google play services.

Hope this help.

kaho
  • 4,746
  • 1
  • 16
  • 24