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 9208195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:33:54+00:00 2026-06-18T00:33:54+00:00

I am creating an app in android 17 and I am trying to include

  • 0

I am creating an app in android 17 and I am trying to include Google Maps v2.

In my current set-up I have an ActionBar with two tabs, one pointing to travel information and one pointing to Google Maps.

I can get Google maps to display in the main activity, but I can’t get the map to display in a fragment.

Here is my Maps Class code:

// Will hold the information for the "Maps" tab
public class Maps extends FragmentActivity {

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

        ActionBar actionBar = getActionBar();
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setCustomView(R.layout.rowlayout);
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // Venue Map

        LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        RelativeLayout layoutView = (RelativeLayout)inflater.inflate(R.layout.action_bar_tab, null);
        TextView tabText = (TextView) layoutView.findViewById(R.id.tabText);
        ImageView tabImage = (ImageView) layoutView.findViewById(R.id.tabImage);

        String venueMapTab = "Travel Information";
        Tab tab = actionBar.newTab();
        TabListener<VenueMap> dayOne = new TabListener<VenueMap>(this,
                venueMapTab, VenueMap.class);
        tab.setTabListener(dayOne); 
        tabText.setText("Venue Map");
        tab.setCustomView(layoutView);
        actionBar.addTab(tab);

        // Google Maps

        RelativeLayout layoutViewMaps = (RelativeLayout)inflater.inflate(R.layout.action_bar_tab, null);
        tabText = (TextView) layoutViewMaps.findViewById(R.id.tabText);
        tabImage = (ImageView) layoutViewMaps.findViewById(R.id.tabImage);

        String googleMapsTab = "Google Maps";
        tab = actionBar.newTab();
        TabListener<GoogleMaps> dayTwo = new TabListener<GoogleMaps>(this,
                googleMapsTab, GoogleMaps.class);
        tab.setTabListener(dayTwo);
        tabText.setText("Google Maps");
        tab.setCustomView(layoutViewMaps);
        actionBar.addTab(tab);

    }

Here is my Google Maps fragment

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    getActivity().setContentView(R.layout.google_maps);
}

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

And my log cat error:

01-28 13:44:09.830: E/AndroidRuntime(22253): FATAL EXCEPTION: main
01-28 13:44:09.830: E/AndroidRuntime(22253): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.zshare.blog/com.zshare.blog.Maps}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.os.Looper.loop(Looper.java:137)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.ActivityThread.main(ActivityThread.java:5039)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at java.lang.reflect.Method.invokeNative(Native Method)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at java.lang.reflect.Method.invoke(Method.java:511)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at dalvik.system.NativeStart.main(Native Method)
01-28 13:44:09.830: E/AndroidRuntime(22253): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.Activity.setContentView(Activity.java:1881)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at com.zshare.blog..VenueMap.onActivityCreated(VenueMap.java:32)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.Fragment.performActivityCreated(Fragment.java:1703)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:903)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1035)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.Activity.onCreateView(Activity.java:4736)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.Activity.setContentView(Activity.java:1881)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at com.zshare.blog.VenueMap.onActivityCreated(VenueMap.java:32)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.Fragment.performActivityCreated(Fragment.java:1703)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:903)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.BackStackRecord.run(BackStackRecord.java:682)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.Activity.performStart(Activity.java:5113)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)
01-28 13:44:09.830: E/AndroidRuntime(22253):    ... 11 more
01-28 13:44:09.830: E/AndroidRuntime(22253): Caused by: java.lang.IllegalArgumentException: Binary XML file line #2: Duplicate id 0x7f05003b, tag null, or parent id 0x1020002 with another fragment for com.google.android.gms.maps.MapFragment
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.app.Activity.onCreateView(Activity.java:4722)
01-28 13:44:09.830: E/AndroidRuntime(22253):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
01-28 13:44:09.830: E/AndroidRuntime(22253):    ... 35 more

If i display the map in an activity it works, but in a fragment I am getting an error. Any help solving this problem would be appreciated 🙂

  • 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-18T00:33:55+00:00Added an answer on June 18, 2026 at 12:33 am

    Since onActivityCreated() is a method on Fragment, it would appear that you are trying to have a fragment load a fragment, which, while possible using the Android Support Library, is not going to work with the native fragments that you are using. It is also unclear why you are doing this in the first place.

    Your “Google Maps fragment” either should be com.google.android.gms.maps.MapFragment or should inherit from com.google.android.gms.maps.MapFragment, but it should not be some separate fragment that tries to load com.google.android.gms.maps.MapFragment.

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

Sidebar

Related Questions

I'm creating an Android app and trying to use Google Places API through Google
I have been creating an app for Android SDK 8 and it works fine.
I have researched a lot about creating my own app for android with a
I'm trying to create a ProgressDialog for an Android-App (just a simple one showing
I'm using two libraries in an android app I'm trying to make. New to
I am creating an Android app and in my app I have a canvas
I am creating a app in android. In that i am using list view.
I am creating an app on android but after hearing about sencha that it
I'm creating an Android app which must do some web surfing in the background
I am creating an android app myself (min sdk version 7 or 2.1 and

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.