I am try to add Google MAP Api v2 in my application.but I am getting exception. Exception is
java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #5: Error inflating class fragment
Here is my xml class
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.MapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
this is my main class
public class MainActivity extends Activity {
private GoogleMap _googleMap=null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
try
{
//loading map
initilizeMap();
_googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
_googleMap.setMyLocationEnabled(true);
} catch (Exception e) {
e.printStackTrace();
}
}
private void initilizeMap() {
if(_googleMap==null)
{
_googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
if (_googleMap == null) {
Toast.makeText(getApplicationContext(),
"Sorry! unable to create maps", Toast.LENGTH_SHORT)
.show();
}
}
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
initilizeMap();
}
}
this is my logcat
01-31 14:20:55.603: E/AndroidRuntime(311): FATAL EXCEPTION: main
01-31 14:20:55.603: E/AndroidRuntime(311): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo/com.example.demo.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.os.Handler.dispatchMessage(Handler.java:99)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.os.Looper.loop(Looper.java:123)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.reflect.Method.invokeNative(Native Method)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.reflect.Method.invoke(Method.java:521)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-31 14:20:55.603: E/AndroidRuntime(311): at dalvik.system.NativeStart.main(Native Method)
01-31 14:20:55.603: E/AndroidRuntime(311): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.Activity.setContentView(Activity.java:1647)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.example.demo.MainActivity.onCreate(MainActivity.java:22)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
01-31 14:20:55.603: E/AndroidRuntime(311): ... 11 more
01-31 14:20:55.603: E/AndroidRuntime(311): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.demo-2.apk]
01-31 14:20:55.603: E/AndroidRuntime(311): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
01-31 14:20:55.603: E/AndroidRuntime(311): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
01-31 14:20:55.603: E/AndroidRuntime(311): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
01-31 14:20:55.603: E/AndroidRuntime(311): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)