1

I am new to Android and I am trying to develop an android app that includes Google maps. The app was working fine on the emulator until I decided to update the Google Play services from revision 7 to 9.

I now get the same error I encountered before ("Google Play services is out of date..."), plus a "fatal exception: main" error. Here is what I get in the logcat:

http://imageshack.us/a/img11/8117/y1mq.png

If I read the logcat correctly, the error is in the MapTabActivity but I don't know if the error is caused by the Google Play services being out of date or if it's something else...

Before updating the Google Play services, the app was working on an emulator with

  • Nexus 4 device
  • Android 4.2.2(API lvl 17)
  • ARM CPU
  • Host GPU selected

I also had to install the com.android.vending.apk and com.google.android.gms.apk that was recommend in other posts about this.

I also added the permission necessary to the manifest and applied for an API key which is also included in the manifest.

Can anyone help me? Here's the MapTabActivity and its corresponding XML.

MapTabActivity.java

package com.dissertation.closethedoordiss;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;

public class MapTabActivity extends FragmentActivity {

private GoogleMap mMap;
private static final LatLng BRISTOL = new LatLng(51.455083,-2.586903);

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


    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapView)).getMap();
    mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);

    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(BRISTOL, 13));
}

public void onClick_addretailer (View view) {
    startActivity(new Intent("com.closethedoordiss.AddRetailerActivity"));
}  
}

activity_maptab.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

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



  <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:src="@android:drawable/ic_menu_add"
        android:onClick="onClick_addretailer"
        android:contentDescription="@string/add_button" />

</RelativeLayout>

Thanks in advance for any help provided.

dakshbhatt21
  • 3,558
  • 3
  • 31
  • 40
PierreM
  • 21
  • 1
  • 7
  • Are you sure installed packages (vending, gms) are latest? This looks like a possible uer-recoverable error on play-services, see http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html#isGooglePlayServicesAvailable(android.content.Context) – Marek Sebera Jul 19 '13 at 09:53
  • I initially used the packages mentioned here [link](http://stackoverflow.com/questions/14040185/running-google-maps-v2-on-android-emulator/17036337#17036337). I also tried installing which I believe were more recent packages but I don't know if they were... The problem still persisted. – PierreM Jul 19 '13 at 10:03
  • Find out what version is required (against which version your code links) and try looking into directory of android SDK (could be somewhere in extras/google play services) – Marek Sebera Jul 19 '13 at 10:04
  • I'm not entirely sure what you're suggesting me to do here... I tried installing more recent packages from here [link](http://www.androidfilehost.com/?fid=23050663588004290) and here [link](http://uploaded.net/file/bnzl1si4) and also tried reverting to Google Play services revision 7 but I still get the same errors... – PierreM Jul 19 '13 at 10:46
  • If I remove `mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(BRISTOL, 13));` from the MapTabActivity.java, the app runs but I get this on the emulator [link](http://img843.imageshack.us/img843/8294/luq.png). – PierreM Jul 19 '13 at 10:54
  • Great, that means you need to find newer version of Google Play Services, don't you think? – Marek Sebera Jul 19 '13 at 10:55
  • That is correct, but installing the latest apk mentioned previously does not solve the problem... – PierreM Jul 19 '13 at 13:53

2 Answers2

1

The only way I have found to run Google Maps Android API v2 is on a physical device.

I am running my app on a Samsung Galaxy S Duos with Android 4.0.4 and the map is displaying correctly.

After trying several solutions, including testing several emulator configurations and installing different apks, I believe the easiest way to overcome the "Google Play Services is out of date" issue when it comes to using Google maps API v2 on an emulator is to develop/test on a physical device.

Hope this helps.

PierreM
  • 21
  • 1
  • 7
0

I've had this issue many times and I've find a couple ways to resolve it. Most likely the Play Services that your app is referencing isn't matching up to what you have on the device, which in this case is the emulator. This might be happening because Google Play (or Google Play Services) isn't installed on the emulator. Check this SO post for more info. If it is installed, you may need to update it. You could update it by installing from scratch if the built-in updating doesn't work.

If you're using the Google Play Services as a library project, you may need to update your Google Play Services library. Here's what I do:

  • Open the SDK manager and see if there's an update to the Google Play Services
  • If there is, download it
  • In eclipse, delete your old Play Services project and import the new one
  • Re-add the new project as a reference

If you're not using the Google Play Services as a library project, or if you've alaready updated, then ignore everything I said above :)

Once your device/emulator and Eclipse project are using the same updated version of the Play Services library, then you should be good to go!

Community
  • 1
  • 1
crocboy
  • 2,887
  • 2
  • 22
  • 25
  • I am using Google Play Services as a library project, and had already done the steps you mentioned here (importing it and referencing it). The errors started showing once I actually updated the Google Play Services (to revision 9). I checked on the emulator and the Google Play Services are installed as they appear in the Settings > Apps menu... I am not sure if this is related but if I open the Google Play Store, a progress dialog appears then it just closes itself... – PierreM Jul 19 '13 at 16:00
  • Try updating the Google Play on the emulator – crocboy Jul 19 '13 at 17:33
  • I tried updating it by just pressing the "Update" button that appears instead of the map but nothing happens. – PierreM Jul 20 '13 at 08:41
  • Hmm... Honestly, I've never used the emulator for maps testing because I found it to flaky. Is there any chance you could use an actual device? – crocboy Jul 21 '13 at 01:24
  • Yes I am currently trying to find a device to test on, as most questions about the Google Maps API v2 on stackoverflow mention that it runs fine on a physical device. I will provide updates on my situation once I get it. Thanks for the help. – PierreM Jul 21 '13 at 08:52
  • No problem. From what I've seen the Play Services architecture is sketchy sometimes, and I wouldn't be surprised if Google switched things up – crocboy Jul 21 '13 at 16:56