3

i do everything, research every but still not working. i read many page from here but not :(

Error logs:

11-18 10:25:46.743: D/AndroidRuntime(24336): Shutting down VM
11-18 10:25:46.743: W/dalvikvm(24336): threadid=1: thread exiting with uncaught exception (group=0x4001d578)
11-18 10:25:46.873: E/AndroidRuntime(24336): FATAL EXCEPTION: main
11-18 10:25:46.873: E/AndroidRuntime(24336): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.gmap/com.example.gmap.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
11-18 10:25:46.873: E/AndroidRuntime(24336):    at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.os.Looper.loop(Looper.java:138)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at android.app.ActivityThread.main(ActivityThread.java:3701)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at java.lang.reflect.Method.invokeNative(Native Method)
11-18 10:25:46.873: E/AndroidRuntime(24336):    at java.lang.reflect.Method.invoke(Method.java:507)

Main Activity:

package com.example.gmap;

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

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        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;
    }

}

Manifest:

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

    <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"/>
<!-- The following two permissions are not required to use
     Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>


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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.gmap.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="AIzaSyDq-Xosuk1Wzyw9WJ4bGjjE6XIhD90QNuA"/>

    </application>

</manifest>

and main xml:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          class="com.google.android.gms.maps.SupportMapFragment"/>

Please any body help meeee.

3 Answers 3

12

Change this

public class MainActivity extends Activity {

to

public class MainActivity extends FragmentActivity {

You need the below

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

In application tag its outside the tag

Sign up to request clarification or add additional context in comments.

5 Comments

@hiddenhazard the meta tag is outside application tag. check developers.google.com/maps/documentation/android/…. also mark the answer as accepted if it helps by clicking the tick next to the answer
I have the same problem with the same catlog but this did not help.
@Cassini why not? what is the problem. If you do it right i see no reason why it won't work. this did not help is vague comment. does not help. I worked for the question poster.
@Raghunandan I used MapFragment inside activity. But is not working samsung duos 2.3.6. Getting InflateException Binary XML file Error inflating class fragment. Same code working for another devices. Xml code <fragment android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.MapFragment" />
@MuraliGanesan you need to use SupportMapFragment if you need map below api level 11
1

I got this error when the one of the permissions were missing in the AndroidManifest.xml file. adding the following permission solved the problem:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

2 Comments

While this may answer the question, it would be best if you could provide some explanation for why it does so, for example what permissions were missing and how did you add the new ones.
@DavidPostill ok, I wrote the permission that caused the error.
0

Remove Demo Map application from your phone. Then will be work fine. That works for me.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.