1

I am learning Android development using a lynda video tutorial.

i am adding the Google-Play-servies to create a maps. i did according to the tutorial, eclipse didn't show any errors but when i try to run it on my emulator and my device. it gives an error unfortunately Mymaps has stopped.

i have added the error and my code below. can anyone tell me how to over come this error. Thank you.

error is

01-28 14:04:55.650: D/AndroidRuntime(1045): Shutting down VM
01-28 14:04:55.693: W/dalvikvm(1045): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
01-28 14:04:55.730: E/AndroidRuntime(1045): FATAL EXCEPTION: main
01-28 14:04:55.730: E/AndroidRuntime(1045): java.lang.RuntimeException: Unable to start activity ComponentInfo{lk.adspace.jaffnatemples/lk.adspace.jaffnatemples.MainActivity}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4132500 but found 0.  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" />
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.os.Looper.loop(Looper.java:137)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.app.ActivityThread.main(ActivityThread.java:5041)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at java.lang.reflect.Method.invokeNative(Native Method)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at java.lang.reflect.Method.invoke(Method.java:511)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at dalvik.system.NativeStart.main(Native Method)
01-28 14:04:55.730: E/AndroidRuntime(1045): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4132500 but found 0.  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" />
01-28 14:04:55.730: E/AndroidRuntime(1045):     at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at lk.adspace.jaffnatemples.MainActivity.servicesOK(MainActivity.java:44)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at lk.adspace.jaffnatemples.MainActivity.onCreate(MainActivity.java:23)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.app.Activity.performCreate(Activity.java:5104)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-28 14:04:55.730: E/AndroidRuntime(1045):     at         android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-28 14:04:55.730: E/AndroidRuntime(1045):     ... 11 more

my code for main_activity (java file)

package lk.adspace.jaffnatemples;

import lk.adspace.jaffnatemples.R;
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;
import 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 for mapping! baman",     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;
}




public boolean servicesOK(){

    int isAvaliable = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);

            if(isAvaliable == ConnectionResult.SUCCESS){

                return true;
            }else if (GooglePlayServicesUtil.isUserRecoverableError(isAvaliable)) {

                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(isAvaliable, this, GPS_ERRORDIALOG_REQUEST);
                dialog.show();
            }else {
                Toast.makeText(this, "Cant connect to google paly services", Toast.LENGTH_SHORT).show();

            }

            return false;

}   

}

my manifest file

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

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />

<permission 
    android:name="lk.adspace.jaffnatemples.permission.MAPS_RECEIVE"
    android:protectionLevel="signature"/>

<uses-permission android:name="lk.adspace.jaffnatemples.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"/>

<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="lk.adspace.jaffnatemples.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="AIzaSyg7tc1ux10tYAgv6hgydfZ4BspLzhRKhld5"/>

</application>

</manifest>
Robin Kanters
  • 5,018
  • 2
  • 20
  • 36
Sathya Baman
  • 3,424
  • 7
  • 44
  • 77
  • 2
    The 4th line of the exception (`java.lang.RuntimeException ...`) tells you exactly what the problem is – Marc B Jan 28 '14 at 14:13
  • possible duplicate of [After Google Play Service update to version 13 I got an error](http://stackoverflow.com/questions/19723811/after-google-play-service-update-to-version-13-i-got-an-error) – laalto Jan 29 '14 at 16:27

1 Answers1

2

///you need to add this line also in your manifest.xml

 <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />

//and you need to add this below line in your values folder in string.xml or integer.xml

 <integer name="google_play_services_version">4132500</integer>
Padma Kumar
  • 19,893
  • 17
  • 73
  • 130