-1

Can anyone clarify where my error is? The Android app crashes with the error, "Unfortunately, my app has stopped working".Just when put fragment in Main_layout file.

<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>  

And here is some of Manifest file

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

All of the permissions are exist in my Manifest file , and I've extended FragmentActivity in java class

Please help me to solve this problem

LogCat: 04-10 23:01:51.963: I/dalvikvm(10356): Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.zzg 04-10 23:01:51.963: W/dalvikvm(10356): VFY: unable to resolve virtual method 369: Landroid/content/pm/PackageManager;.getPackageInstaller ()Landroid/content/pm/PackageInstaller; 04-10 23:01:51.963: D/dalvikvm(10356): VFY: replacing opcode 0x6e at 0x000b 04-10 23:01:51.963: D/AndroidRuntime(10356): Shutting down VM 04-10 23:01:51.963: W/dalvikvm(10356): threadid=1: thread exiting with uncaught exception (group=0x41907d88) 04-10 23:01:51.983: E/AndroidRuntime(10356): FATAL EXCEPTION: main 04-10 23:01:51.983: E/AndroidRuntime(10356): Process: com.example.myapp, PID: 10356 04-10 23:01:51.983: E/AndroidRuntime(10356): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class fragment 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2237) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2286) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.ActivityThread.access$800(ActivityThread.java:144) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1246) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.os.Handler.dispatchMessage(Handler.java:102) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.os.Looper.loop(Looper.java:212) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.ActivityThread.main(ActivityThread.java:5135) 04-10 23:01:51.983: E/AndroidRuntime(10356): at java.lang.reflect.Method.invokeNative(Native Method) 04-10 23:01:51.983: E/AndroidRuntime(10356): at java.lang.reflect.Method.invoke(Method.java:515) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693) 04-10 23:01:51.983: E/AndroidRuntime(10356): at dalvik.system.NativeStart.main(Native Method) 04-10 23:01:51.983: E/AndroidRuntime(10356): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class fragment 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.view.LayoutInflater.inflate(LayoutInflater.java:492) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.view.LayoutInflater.inflate(LayoutInflater.java:397) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.view.LayoutInflater.inflate(LayoutInflater.java:353) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:297) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.Activity.setContentView(Activity.java:1929) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.example.myapp.MainActivity.onCreate(MainActivity.java:23) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.Activity.performCreate(Activity.java:5231) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2201) 04-10 23:01:51.983: E/AndroidRuntime(10356): ... 11 more 04-10 23:01:51.983: E/AndroidRuntime(10356): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 7095000 but found 0. You must have the following declaration within the element: 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.common.GooglePlayServicesUtil.zzJ(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.maps.internal.zzx.zzad(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.maps.internal.zzx.zzac(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.maps.SupportMapFragment$zzb.zzqs(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.maps.SupportMapFragment$zzb.zza(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.dynamic.zza.zza(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.dynamic.zza.onInflate(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:279) 04-10 23:01:51.983: E/AndroidRuntime(10356): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685) 04-10 23:01:51.983: E/AndroidRuntime(10356): ... 21 more 04-10 23:01:54.903: I/Process(10356): Sending signal. PID: 10356 SIG: 9

And this is the manifest file

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

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<!-- Maps API needs OpenGL ES 2.0. -->
<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" >

    <!-- You must insert your own Google Maps for Android API v2 key in here. -->
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyA--------------------ZQjV4U" />

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

    <activity
        android:name="com.example.myapp.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>

  • Follow instructions here: https://developers.google.com/maps/documentation/android/start#add_a_map I got it set up that way the other day, it was super easy. You also might find an answer I posted the other day useful: http://stackoverflow.com/questions/29505087/cannot-add-map-in-android-studio-as-stated-in-google-getting-started-page-and/29505604#29505604 – Daniel Nugent Apr 10 '15 at 18:19
  • @Raptor42 that is the logCat – Fareez Azèem Apr 10 '15 at 20:05

1 Answers1

0

Looks like an error lies in your manifest - Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 7095000 but found 0

I cannot see the content of your manifest file, but my first guess is that you didn't set up Google Play services version or google maps api key meta-data in manifest properly. Everything is explained there: https://developers.google.com/maps/documentation/android/start#add_a_map just like @Daniel Nugent mentioned.

Raptor42
  • 391
  • 2
  • 10
  • hmm.. take a look at this section: `` try clicking on `google_play_services_version` with middle mouse button or rmb - goto - declaration and see what number shows up. If it is 0, try changing to 7095000 – Raptor42 Apr 10 '15 at 21:52
  • I can't find what you talkin about, Where is that? – Fareez Azèem Apr 10 '15 at 22:03
  • Yes , but I meant about 'declaration and see what number shows up' – Fareez Azèem Apr 10 '15 at 22:07
  • click right mouse button on gpsv then scroll to Go to and select delcaration. Ctrl + B is the shortcut – Raptor42 Apr 10 '15 at 22:10
  • There is no something like that nor Ctrl + B – Fareez Azèem Apr 10 '15 at 22:13
  • if it won't work then check in build.gradle if you haven't forgot to add "compile 'com.google.android.gms:play-services.." to dependencies. Everything you need to do is in the link in the my main answer. I quit trying to explain to you how to use mouse and how to click, as there's past midnight in my timezone and i need to go to sleep... – Raptor42 Apr 10 '15 at 22:17
  • hhhhh i use Eclipse not android studio – Fareez Azèem Apr 10 '15 at 22:22