Ihsan chahi
Ihsan chahi

Reputation: 307

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

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

Upvotes: 1

Views: 4189

Answers (4)

Irshad A Khan
Irshad A Khan

Reputation: 143

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

Upvotes: 1

Shani Goriwal
Shani Goriwal

Reputation: 2104

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

Upvotes: 1

Ihsan chahi
Ihsan chahi

Reputation: 307

Resolved Thanks to all for your suggestions.

<Meta> Tag should be in <Application> Tag.

Upvotes: 4

pshegger
pshegger

Reputation: 2596

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

Upvotes: 1

Related Questions