Skip to content Skip to sidebar Skip to footer

Inflating Google Maps V2 Fragment Causes Classnotfoundexception

Sorry i am posting this question on. I have refered so many links. But still not able to solve the issue I have linked the google-play-services_lib service. Set the property to Go

Solution 1:

If you're using fragments on older devices (pre Honeycomb) you should always extend your Activity from FragmentActivity.

So, solution for your problem: change your MapViews class to extend FragmentActivity.

import android.support.v4.app.FragmentActivity;

publicclassMapViewsextendsFragmentActivity {
  ...

More info and a complete example: http://android-er.blogspot.co.uk/2012/12/using-supportmapfragment.html

Explanation:

The exception what is important here is: java.lang.ClassNotFoundException: android.view.fragment.

The reason for this is that on pre-Honeycomb devices when the Activity tries to load the xml layout it finds the keyword fragment which it can't understand so it tries to load it as a simple built-in view class (android.view.fragment).

If you extend FragmentActivity the setContentView method is overridden so it can process the fragment keyword.

Solution 2:

There's something wrong in your layout. Just try to define MapView like this:

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="Your Maps API Key goes here"
/>

Post a Comment for "Inflating Google Maps V2 Fragment Causes Classnotfoundexception"