Google Maps API Android - Error inflating class fragment

I know that there are many topics on StackOverFlow regarding this problem, however none of them could help me. I am doing a very basic application which I just want to display a MAP.

  • I Have imported the google-play-services_lib to my main project.
  • I have generated my API Key.

This is my AndroidManifest.xml file:

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

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

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

    <uses-permission android:name="com.linkme2night.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <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" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.linkme2night.view.interactwithvenue.InteractWithVenueActivity"
            android:label="@string/app_name" >
        </activity>
        <activity
            android:name="com.linkme2night.view.openvenuesmap.OpenVenuesMapActivity"
            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="AIzaSyBJVHZJr1Q14fcvEHBkAUT1A_ZH4eQlnrI" />
    </application>

</manifest>

This is my Layout XML file:

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/the_map"
    android:name="com.google.android.gms.maps.SupportMapFragment "
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

This is my code:

public class OpenVenuesMapActivity extends FragmentActivity  {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_open_venues_map);
    }
}

I am running the application on my Sony XPeria J. I get the following Error generated by Loc Cat:

05-01 18:51:48.544: E/AndroidRuntime(10794): FATAL EXCEPTION: main
05-01 18:51:48.544: E/AndroidRuntime(10794): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.linkme2night/com.linkme2night.view.openvenuesmap.OpenVenuesMapActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2065)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2090)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.access$600(ActivityThread.java:136)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.os.Handler.dispatchMessage(Handler.java:99)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.os.Looper.loop(Looper.java:137)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.main(ActivityThread.java:4802)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.reflect.Method.invokeNative(Native Method)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.reflect.Method.invoke(Method.java:511)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:813)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:580)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at dalvik.system.NativeStart.main(Native Method)
05-01 18:51:48.544: E/AndroidRuntime(10794): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class fragment
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.Activity.setContentView(Activity.java:1869)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at com.linkme2night.view.openvenuesmap.OpenVenuesMapActivity.onCreate(OpenVenuesMapActivity.java:14)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.Activity.performCreate(Activity.java:5013)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2029)
05-01 18:51:48.544: E/AndroidRuntime(10794):    ... 11 more
05-01 18:51:48.544: E/AndroidRuntime(10794): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment : make sure class name exists, is public, and has an empty constructor that is public
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.Fragment.instantiate(Fragment.java:401)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:676)
05-01 18:51:48.544: E/AndroidRuntime(10794):    ... 20 more
05-01 18:51:48.544: E/AndroidRuntime(10794): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.SupportMapFragment 
05-01 18:51:48.544: E/AndroidRuntime(10794):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-01 18:51:48.544: E/AndroidRuntime(10794):    at android.support.v4.app.Fragment.instantiate(Fragment.java:391)
05-01 18:51:48.544: E/AndroidRuntime(10794):    ... 23 more

This is what I get when I create the google-service-lib from existing code, located in my C:/Program Files/eclipse/SDKs/... , and then import it on my project:

Does anyone one know What else can I be missing? I am starting to get desperated with this simple thing...

Answers


Your min sdk is 11. You will need to add support library for api versions below 12

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

Fragments were introduced in HoneyComb. So for backward compatibality you need add support library

 android:name="com.google.android.gms.maps.SupportMapFragment "

Since you din't add support library you got classcastexception

To add support library check the link below

http://developer.android.com/tools/extras/support-library.html


Need Your Help

Using scope_identity() with ASP.NET controls

c# asp.net sql database

I've built a form for entering some data into a table in my database, now I want to INSERT that data, and get back the ID (which is an autonumber) of the record that has just been added. I've got the

Apply Indicator Function to List

python list function indicator

Is there an easy way to apply an indicator function to a list? i.e. I have a list with some numbers in it and I would like to return another list of the same size with, for example, ones where the

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.