Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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

share|improve this question
    
is this the whole xml layout file? If not could You please post the complete one? –  Opiatefuchs Aug 1 '13 at 8:26

4 Answers 4

up vote 3 down vote accepted

Resolved Thanks to all for your suggestions.

<Meta> Tag should be in <Application> Tag.
share|improve this answer

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

share|improve this answer

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"/>
share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.