1

i'am new in Android programming i have a problem. When my code running i give error "Unfortunately [app] has Stopped" in my device screen.

This is my Activity

package com.android.markermap;


import android.app.Activity;
    import android.os.Bundle;
    import android.view.Menu;

    import com.google.android.gms.maps.CameraUpdateFactory;
    import com.google.android.gms.maps.GoogleMap;
    import com.google.android.gms.maps.MapFragment;
    import com.google.android.gms.maps.model.BitmapDescriptorFactory;
    import com.google.android.gms.maps.model.LatLng;
    import com.google.android.gms.maps.model.Marker;
    import com.google.android.gms.maps.model.MarkerOptions;

    public class MainActivity extends Activity {
      static final LatLng BANDUNG = new LatLng(-6.904955,107.61034);
      static final LatLng BOGOR = new LatLng(-6.589581,106.799755);
      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();
        Marker bandung = map.addMarker(new MarkerOptions().position(BANDUNG).title("Berat"));
        Marker bogor = map.addMarker(new MarkerOptions().position(BOGOR).title("Ringan").snippet("Kiel is cool"));

        // Move the camera instantly to hamburg with a zoom of 15.
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(BANDUNG, 12));

        // Zoom in, animating the camera.
        map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
      }

      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
      }

    }

This is my layout code

<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"
    tools:context=".MainActivity" >

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

</RelativeLayout>

This is my manifest

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

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

    <permission
        android:name="com.android.markermap.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

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

    <uses-permission android:name="com.android.markermap.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.android.markermap.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="AIzaSyC-0N7OEKJmId5HnKYNsbU6IBaSIgiF7Lc" />
    </application>

</manifest>

And this is my error code

11-30 23:39:58.071: W/dalvikvm(16870): threadid=1: thread exiting with uncaught exception (group=0x40c64438)
11-30 23:39:58.071: E/AndroidRuntime(16870): FATAL EXCEPTION: main
11-30 23:39:58.071: E/AndroidRuntime(16870): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.markermap/com.android.markermap.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2067)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2092)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.ActivityThread.access$600(ActivityThread.java:133)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1203)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.os.Looper.loop(Looper.java:137)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.ActivityThread.main(ActivityThread.java:4810)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at java.lang.reflect.Method.invokeNative(Native Method)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at java.lang.reflect.Method.invoke(Method.java:511)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at dalvik.system.NativeStart.main(Native Method)
11-30 23:39:58.071: E/AndroidRuntime(16870): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:262)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.Activity.setContentView(Activity.java:1867)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.android.markermap.MainActivity.onCreate(MainActivity.java:23)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.Activity.performCreate(Activity.java:5008)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2031)
11-30 23:39:58.071: E/AndroidRuntime(16870):    ... 11 more
11-30 23:39:58.071: E/AndroidRuntime(16870): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 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" />
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.maps.MapFragment$b.cE(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.dynamic.a.a(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.app.Activity.onCreateView(Activity.java:4663)
11-30 23:39:58.071: E/AndroidRuntime(16870):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
11-30 23:39:58.071: E/AndroidRuntime(16870):    ... 21 more

Anyonee have ide for this problem? i'am very confuse, i hope u can solve this problem.

  • Same question http://stackoverflow.com/questions/19723811/after-google-play-service-update-to-version-13-i-got-an-error – Bobbake4 Nov 30 '13 at 17:12

2 Answers2

0

actually reading the error help a lot you know

The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 4030500 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" />

tyczj
  • 71,600
  • 54
  • 194
  • 296
0

Your code is fine but for Google play service revision 13 you should have to add one more meta tag in your manifest.xml.Insert it inside your application tag.So there will be two meta tags in your application tag.If you still need any help.Just follow this link

    <meta-data  android:name="com.google.android.gms.version" android:value="4030500" />
Talha Q
  • 4,350
  • 4
  • 28
  • 40