1

i have the following code and i am using sherlockfragments.

 map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
            .findFragmentById(R.id.map)).getMap();

<?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="450px"
          android:name="com.google.android.gms.maps.SupportMapFragment"/>

and i am getting error:

android.view.InflateException: Binary XML file line #94: Error inflating class fragment

1
  • is this the whole xml layout file? If not could You please post the complete one? Commented Aug 1, 2013 at 8:26

4 Answers 4

4

Resolved Thanks to all for your suggestions.

<Meta> Tag should be in <Application> Tag.
Sign up to request clarification or add additional context in comments.

Comments

1

I'm not sure if it's the correct answer, but try to put your fragment inside a ViewGroup, it may solve the problem.

Comments

1

try yo use this:

private GoogleMap MAP;  

FragmentManager myFM = getSupportFragmentManager();  
       SupportMapFragment myMAPF = (SupportMapFragment) myFM  
                 .findFragmentById(R.id.map);

MAP = myMAPF.getMap();

Also you have to change it with:

<?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="450px"
      android:name="com.google.android.gms.maps.SupportMapFragment"/>

to

<?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="450px"
      class="com.google.android.gms.maps.SupportMapFragment"/>

Comments

1

Try removing the getActivity()..

map = ((SupportMapFragment) getActivity().getSupportFragmentManager()
        .findFragmentById(R.id.map)).getMap();

just try with change by:

map = ((SupportMapFragment) getSupportFragmentManager()
        .findFragmentById(R.id.map)).getMap();

It did worked for me ...hope it would do for you also

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.