0

I am using google map V2 to display marker for static latitude and longitude

but it gives me error

Caused by: java.lang.ClassNotFoundException:  
com.example.gpstracker.GpsMapActivity in loader dalvik.system.PathClassLoader

GpsMapActivity class

public class GpsMapActivity 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;

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


    map = ((SupportMapFragment) getSupportFragmentManager().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)));
        }*/
        map.setMyLocationEnabled(false);
        map.moveCamera(CameraUpdateFactory.newLatLng(HAMBURG));
        map.animateCamera(CameraUpdateFactory.zoomTo(15));
    }



  }

activity_gps_map

<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=".GpsMapActivity" >

<TextView
    android:id="@+id/tv_location"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

 <fragment 
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@id/tv_location"
    class="com.google.android.gms.maps.SupportMapFragment" />
</RelativeLayout>

manifest file

 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.gpstracker"
 android:versionCode="1"
 android:versionName="1.0" >
 <permission
    android:name="com.example.gpstracker.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

 <uses-permission android:name="com.example.gpstracker.permission.MAPS_RECEIVE" />

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

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
 <uses-permission android:name="android.permission.INTERNET" />
 <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

 <!-- Required to show current location -->
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

 <!-- Required OpenGL ES 2.0. for Maps V2 -->
 <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" >
    <activity
        android:name="com.example.gpstracker.GpsMapActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <!-- Goolge API Key -->
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyA9hiBWVBm6U5VuKBAKyyz_niMTrj42wco" />
    </application>

    </manifest>
Looking Forward
  • 3,579
  • 8
  • 45
  • 65
HemangNirmal
  • 621
  • 1
  • 8
  • 24

0 Answers0