i am following tutorial for using google maps api v2 .i am facing an error error logs are
05-15 00:08:18.415: E/AndroidRuntime(4547): FATAL EXCEPTION: main
05-15 00:08:18.415: E/AndroidRuntime(4547): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.rtesh.onemore/org.rtesh.onemore.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.ActivityThread.access$1500(ActivityThread.java:132)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.os.Handler.dispatchMessage(Handler.java:99)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.os.Looper.loop(Looper.java:150)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.ActivityThread.main(ActivityThread.java:4277)
05-15 00:08:18.415: E/AndroidRuntime(4547): at java.lang.reflect.Method.invokeNative(Native Method)
05-15 00:08:18.415: E/AndroidRuntime(4547): at java.lang.reflect.Method.invoke(Method.java:507)
05-15 00:08:18.415: E/AndroidRuntime(4547): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
05-15 00:08:18.415: E/AndroidRuntime(4547): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
05-15 00:08:18.415: E/AndroidRuntime(4547): at dalvik.system.NativeStart.main(Native Method)
05-15 00:08:18.415: E/AndroidRuntime(4547): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class fragment
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-15 00:08:18.415: E/AndroidRuntime(4547): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.Activity.setContentView(Activity.java:1712)
05-15 00:08:18.415: E/AndroidRuntime(4547): at org.rtesh.onemore.MainActivity.onCreate(MainActivity.java:27)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794)
05-15 00:08:18.415: E/AndroidRuntime(4547): ... 11 more
05-15 00:08:18.415: E/AndroidRuntime(4547): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.support.v4.app.Fragment.instantiate(Fragment.java:395)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.support.v4.app.Fragment.instantiate(Fragment.java:363)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:264)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
05-15 00:08:18.415: E/AndroidRuntime(4547): ... 20 more
05-15 00:08:18.415: E/AndroidRuntime(4547): Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.MapFragment in loader dalvik.system.PathClassLoader[/data/app/org.rtesh.onemore-1.apk]
05-15 00:08:18.415: E/AndroidRuntime(4547): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-15 00:08:18.415: E/AndroidRuntime(4547): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-15 00:08:18.415: E/AndroidRuntime(4547): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-15 00:08:18.415: E/AndroidRuntime(4547): at android.support.v4.app.Fragment.instantiate(Fragment.java:385)
05-15 00:08:18.415: E/AndroidRuntime(4547): ... 23 more
my MainActivity class is
@SuppressLint("NewApi")
public class MainActivity extends FragmentActivity {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
private GoogleMap map;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
if (map!=null){
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
}
}
}
and activity_main.xml is
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
i gave appropriate permissions in maifest class
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.rtesh.onemore"
android:versionCode="1"
android:versionName="1.0" >
<permission
android:name="org.rtesh.android.locationapi.maps.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-permission android:name="com.org.rtesh.android.locationapi.maps.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="org.rtesh.onemore.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="mykey" />
</application>
</manifest>
i referenced the google play service library why i am facing this error ??please some one help and please point the major differences between google maps version1 and 2!!