Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9054961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:49:23+00:00 2026-06-16T13:49:23+00:00

I am trying to add a Google Maps view using the version 2 API

  • 0

I am trying to add a Google Maps view using the version 2 API to the built in Android Master Detail flow. For some reason I am getting a error inflating class fragment exception:

    12-29 22:47:05.828: E/AndroidRuntime(1655): FATAL EXCEPTION: main
12-29 22:47:05.828: E/AndroidRuntime(1655): android.view.InflateException: Binary XML file line #48: Error inflating class fragment
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at com.reading.trackitparent.MapDetailFragment.onCreateView(MapDetailFragment.java:52)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:911)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.os.Handler.handleCallback(Handler.java:605)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.os.Handler.dispatchMessage(Handler.java:92)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.os.Looper.loop(Looper.java:137)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.app.ActivityThread.main(ActivityThread.java:4424)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at java.lang.reflect.Method.invokeNative(Native Method)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at java.lang.reflect.Method.invoke(Method.java:511)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at dalvik.system.NativeStart.main(Native Method)
12-29 22:47:05.828: E/AndroidRuntime(1655): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.MapFragment cannot be cast to android.support.v4.app.Fragment
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.Fragment.instantiate(Fragment.java:394)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.Fragment.instantiate(Fragment.java:369)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:272)
12-29 22:47:05.828: E/AndroidRuntime(1655):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)

I have created a new MapDetailFragment:

package com.reading.trackitparent;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.reading.trackitparent.dummy.DummyContent;

/**
 * A fragment representing a single Item detail screen. This fragment is either
 * contained in a {@link ItemListActivity} in two-pane mode (on tablets) or a
 * {@link ItemDetailActivity} on handsets.
 */
public class MapDetailFragment extends Fragment {
    /**
     * The fragment argument representing the item ID that this fragment
     * represents.
     */
    public static final String ARG_ITEM_ID = "item_id";

    /**
     * The dummy content this fragment is presenting.
     */
    private DummyContent.DummyItem mItem;

    /**
     * Mandatory empty constructor for the fragment manager to instantiate the
     * fragment (e.g. upon screen orientation changes).
     */
    public MapDetailFragment() {
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (getArguments().containsKey(ARG_ITEM_ID)) {
            // Load the dummy content specified by the fragment
            // arguments. In a real-world scenario, use a Loader
            // to load content from a content provider.
            mItem = DummyContent.ITEM_MAP.get(getArguments().getString(
                    ARG_ITEM_ID));
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_map_detail,
                container, false);

//      // Show the dummy content as text in a TextView.
//      if (mItem != null) {
//          ((TextView) rootView.findViewById(R.id.item_detail))
//                  .setText(mItem.content);
//      }

        return rootView;
    }
}

and I am trying to use the following layout:

<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=".ItemDetailActivity" >

    <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.MapFragment" />

</RelativeLayout>

ItemListActivity:

package com.reading.trackitparent;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

/**
 * An activity representing a list of Items. This activity has different
 * presentations for handset and tablet-size devices. On handsets, the activity
 * presents a list of items, which when touched, lead to a
 * {@link ItemDetailActivity} representing item details. On tablets, the
 * activity presents the list of items and item details side-by-side using two
 * vertical panes.
 * <p>
 * The activity makes heavy use of fragments. The list of items is a
 * {@link ItemListFragment} and the item details (if present) is a
 * {@link ItemDetailFragment}.
 * <p>
 * This activity also implements the required {@link ItemListFragment.Callbacks}
 * interface to listen for item selections.
 */
public class ItemListActivity extends FragmentActivity implements
        ItemListFragment.Callbacks {

    /**
     * Whether or not the activity is in two-pane mode, i.e. running on a tablet
     * device.
     */
    private boolean mTwoPane;

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

        if (findViewById(R.id.item_detail_container) != null) {
            // The detail container view will be present only in the
            // large-screen layouts (res/values-large and
            // res/values-sw600dp). If this view is present, then the
            // activity should be in two-pane mode.
            mTwoPane = true;

            // In two-pane mode, list items should be given the
            // 'activated' state when touched.
            ((ItemListFragment) getSupportFragmentManager().findFragmentById(
                    R.id.item_list)).setActivateOnItemClick(true);
        }

        // TODO: If exposing deep links into your app, handle intents here.
    }

    /**
     * Callback method from {@link ItemListFragment.Callbacks} indicating that
     * the item with the given ID was selected.
     */
    @Override
    public void onItemSelected(String id) {
        if (mTwoPane) {
            // In two-pane mode, show the detail view in this activity by
            // adding or replacing the detail fragment using a
            // fragment transaction.
            Bundle arguments = new Bundle();
            arguments.putString(MapDetailFragment.ARG_ITEM_ID, id);
            MapDetailFragment fragment = new MapDetailFragment();
            fragment.setArguments(arguments);
            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.item_detail_container, fragment).commit();

        } else {
            // In single-pane mode, simply start the detail activity
            // for the selected item ID.
            Intent detailIntent = new Intent(this, ItemDetailActivity.class);
            detailIntent.putExtra(MapDetailFragment.ARG_ITEM_ID, id);
            startActivity(detailIntent);
        }
    }
}

I have referenced the Google Play Services Libs. My manifest looks like so:

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

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

    <uses-permission android:name="com.reading.trackitparent.permission.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" />

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.reading.trackitparent.ItemListActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.reading.trackitparent.ItemDetailActivity"
            android:label="@string/title_item_detail" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value=".ItemListActivity" />
        </activity>

        <uses-library android:name="com.google.android.maps" />
    </application>

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxx" />

</manifest>

I would really appreciate any help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:49:25+00:00Added an answer on June 16, 2026 at 1:49 pm

    Replace MapFragment with SupportMapFragment. SupportMapFragment is the one to use with the Android Support package backport of fragments. MapFragment is for the native API Level 11 version of fragments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

NOTE: I'm using v3 of the Google Maps API I'm trying to add an
I am trying to use the Google maps API on my android app. I
I'm trying to add markers to a Google maps using V3. I have my
I'm trying to add pin/address annotations in my Google maps view. When I do
I'm working on a GWT app that's using Google Maps. I'm trying to add
I'm trying to add some custom controls to Google Maps and style them with
I'm trying to add custom controls to a Google map using the API. I
I am trying to add google maps to my android application, and I followed
I am trying to get a google API key to add google maps to
I am trying to use the Google Map API- I've successfully managed to add

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.