I am getting this error "Unfortunately, My Map has stopped" on my phone whenever I try to run this application ("My Map" is the name of the application ).
my google_services is version 17
does anyone know how can I fix this?
**solution:**after 2 frustrating days I found the solution for the problem:
so it's not enough to add this to the manifest file as a son of the application tag:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="@string/app_key"/> //app_key is the value of my api key
you should also have the integer initialized to 4452000 and not 4132500 as I someone said in another post. (this can be added to the string folder)
<integer name="google_play_services_version">4452000</integer>
MainActivity.java
package com.seminarion.shiran;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
android.view.Menu;
import android.widget.Toast;
public class MainActivity extends Activity {
private static final int GPS_ERRORDIALOG_REQUEST = 9001;
GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(servicesOK()){
Toast.makeText(this, "Ready to map!", Toast.LENGTH_SHORT).show();
}
setContentView(R.layout.activity_main);
}
@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;
}
//this method checking whether the google play kit services are installed in the device of the user and
//letting the user know his current status.
public boolean servicesOK() {
int isAvailable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
//IF I get a value of success that's mean googlePlay services is installed
//and we can display a map
if (isAvailable == ConnectionResult.SUCCESS) {
return true;
}
else if (GooglePlayServicesUtil.isUserRecoverableError(isAvailable)) {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvailable, this, GPS_ERRORDIALOG_REQUEST);
dialog.show();
}
else {
//error which is not recoverd by the user . we simply show the user an error message
Toast.makeText(this, "Can't connect to Google Play services", Toast.LENGTH_SHORT).show();
}
return false;
}
}
Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.seminarion.shiran"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission android:name="com.seminarion.shiran.permission.MAPS_RECEIVE"
protectionLevel="signature"/>
<uses-permission android:name="com.seminarion.shiran.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.provider.gsf.permission.READ_GSERVICES"
/>
<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" >
<activity
android:name="com.seminarion.shiran.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>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="Here is my key..." //API KEY
/>
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
</manifest>
LogCat:
05-27 12:54:46.205: D/AndroidRuntime(10437): Shutting down VM
05-27 12:54:46.205: W/dalvikvm(10437): threadid=1: thread exiting with uncaught exception (group=0x40ff4930)
05-27 12:54:46.205: E/AndroidRuntime(10437): FATAL EXCEPTION: main
05-27 12:54:46.205: E/AndroidRuntime(10437): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.seminarion.shiran/com.seminarion.shiran.MainActivity}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4452000 but found 4132500. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2296)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.ActivityThread.access$700(ActivityThread.java:151)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.os.Handler.dispatchMessage(Handler.java:99)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.os.Looper.loop(Looper.java:137)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.ActivityThread.main(ActivityThread.java:5293)
05-27 12:54:46.205: E/AndroidRuntime(10437): at java.lang.reflect.Method.invokeNative(Native Method)
05-27 12:54:46.205: E/AndroidRuntime(10437): at java.lang.reflect.Method.invoke(Method.java:511)
05-27 12:54:46.205: E/AndroidRuntime(10437): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
05-27 12:54:46.205: E/AndroidRuntime(10437): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
05-27 12:54:46.205: E/AndroidRuntime(10437): at dalvik.system.NativeStart.main(Native Method)
05-27 12:54:46.205: E/AndroidRuntime(10437): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4452000 but found 4132500. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
05-27 12:54:46.205: E/AndroidRuntime(10437): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)
05-27 12:54:46.205: E/AndroidRuntime(10437): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
05-27 12:54:46.205: E/AndroidRuntime(10437): at com.seminarion.shiran.MainActivity.servicesOK(MainActivity.java:40)
05-27 12:54:46.205: E/AndroidRuntime(10437): at com.seminarion.shiran.MainActivity.onCreate(MainActivity.java:23)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.Activity.performCreate(Activity.java:5250)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)
05-27 12:54:46.205: E/AndroidRuntime(10437): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2210)
05-27 12:54:46.205: E/AndroidRuntime(10437): ... 11 more