1

problem is "java.lang.ClassNotFoundExeption: com.google.android.gms.maps.MapFragment"

i followed this video http://www.youtube.com/watch?v=awX5T-EwLPc my eclipse is Eclipse IDE for Java Developers, Version: Juno Service Release 2 adt - ADT 22.0 i include google play service v5 (because if v7 my emulator ask to get update for google play) it is a simple project, i don't know what can be easer than this please i am fresh in this area and i spent whole week and didn't solve this problem

AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.googlemapv2demo"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17" />

    <permission     
        android:name="com.example.googlemapv2demo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature"/>
    <uses-permission android:name="com.example.googlemapv2demo.permission.MAPS_RECEIVE"/>    

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
    <!-- The following two permissions are not required to use
         Google Maps Android API v2, but are recommended. -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true"/>


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyAoZvfHoOtBXenGq0OC2itsW4hFa5Tmjuw"/>

        <activity
            android:name="com.example.googlemapv2demo.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>
    </application>

</manifest>

activite_main.xml
<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"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

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

</RelativeLayout>


MainActivity.java
package com.example.googlemapv2demo;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
  • 1
    http://stackoverflow.com/questions/16636039/java-lang-classnotfoundexception-after-changing-nothing-in-the-project-but-upgra/16636127#16636127. try this if you have updated adt to rev 22. Also you need to test your app on your device not emulator. you can check this if you want to run it on emulator. However i have not tested this myself – Raghunandan May 25 '13 at 19:46
  • http://blog-emildesign.rhcloud.com/?p=527 for runnign map on emulator – Raghunandan May 25 '13 at 19:52
  • it didn't help this link what you posted i saw here and followed instruction it helped to solve proble with update google play service but current problem is that my project crashed – Sergei Shevchenko May 25 '13 at 20:09
  • I solvde my problem by installing the packege SDK (which includes eclipse for developers) and using this tutorial - http://android-er.blogspot.com/2012/12/a-simple-example-using-google-maps.html – Sergei Shevchenko May 28 '13 at 23:47

1 Answers1

1

MapFragment is only available from api level 12 and according to your manifest you are supporting older vsersions as well. So in order to run your app please use SupportMapFragment from the support library released by google.

nikhil.thakkar
  • 1,093
  • 7
  • 12
  • it didn't helped i changed this "public class MainActivity extends FragmentActivity" and this "android:name="com.google.android.gms.maps.SupportMapFragment" the problem is now "java.lang.ClassNotFoundExeption: com.google.android.gms.maps.SupportMapFragment" – Sergei Shevchenko May 25 '13 at 21:01
  • Check if the support library is present in your libs folder. – nikhil.thakkar May 25 '13 at 21:02
  • here is android private libraries > C:\Users\+++\workspace\GoogleMapV2Demo\libs\android-support-v4.jar – Sergei Shevchenko May 25 '13 at 21:18