0

I want to show Map in my application and tried it using Google Map API v2. But I am facing a problem ClassNotFoundException: com.google.android.gms.maps.MapFragment at runtime. Bellow is the code.

  1. Activity Class:

    public class MainActivity extends FragmentActivity { MapFragment mapFragment; SupportMapFragment supportMapFragment; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } }

    1. XML layout

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    

    1. manifest file

     <uses-sdk
        android:maxSdkVersion="19"
        android:minSdkVersion="8"
        android:targetSdkVersion="19" />
    
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    
    <permission
        android:name="com.xerces.mapsample.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />
    
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <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-permission android:name="com.xerces.mapsample.permission.MAPS_RECEIVE" />
    
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".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="MAP API KEY" />
    </application>
    

I am using google play service library in my project as per mention in tutorials or android developers guide.

So could any body help me on this. I have wasted my too much time on this.

Bellow screenshot contains my library structure... enter image description here

Sanket Patel
  • 135
  • 1
  • 2
  • 9
  • 1
    possible duplicate of http://stackoverflow.com/questions/16572020/error-java-lang-classnotfoundexception-com-google-android-gms-maps-mapfragment – Nadir Belhaj Oct 07 '14 at 14:40
  • Yes it may be duplicate. but there is no such answer which will solve my question. Because i am not using .jar file. I have added google play service lib properly in my project. – Sanket Patel Oct 08 '14 at 04:51

1 Answers1

0
dependencies {
    compile 'com.google.android.gms:play-services:7.0.0'
}
Ced
  • 15,847
  • 14
  • 87
  • 146