Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mapview in MapActivity Class not found

I've seen other threads here with similar symptoms, but none of the answers solved my problem. I'm following the Google map view tutorial, http://developer.android.com/resources/tutorials/views/hello-mapview.html and following all directions exactly, I keep getting this error .. java.lang.ClassNotFoundException: com.goodintechnology.maps.Mymap in loader dalvik.system.PathClassLoader[/data/app/com.goodintechnology.maps-1.apk]

I've started from scratch many times, but everytime, as soon as I change the Activity to MapActivity, the error is thrown. The app target is Google API 2.2, and the emulator is the same, with GPS enabled. I've tried putting the uses-library statement before, after, and in the Applications statement, but that didn't change anything. I even tried putting the statement vertically in the manifest. So, after about 8 hours messing with this, I put it to all of you. Here's the code:

AndroidManifest.xml

<uses-library android:name="com.google.android.maps" />
<uses-permission android:name="android.permission.INTERNET" />

<application android:icon="@drawable/icon" android:label="@string/app_name">
    <activity android:name=".Mymap"
              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>

and the layout main.xml

<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/mapview"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="My key that was generated on google is here. trust me"
/>
</LinearLayout>

And the class Mymap

package com.goodintechnology.maps;
import com.google.android.maps.MapActivity;
import android.os.Bundle;

public class Mymap extends MapActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}
}

As mentioned this is all straight from Google Map View tutorial.

like image 493
Poolczar Avatar asked Mar 06 '11 22:03

Poolczar


2 Answers

<uses-library android:name="com.google.android.maps" />

must be within <application> </application>

You said you tried that, but how you currently have it, it wont't work by any chance, so change that first.

like image 163
icyerasor Avatar answered Oct 05 '22 05:10

icyerasor


Looks like maps.jar is not included in your project folder.

First of all put following line as child of application in your manifest file

<uses-library android:name="com.google.android.maps" />

After that right click on your project folder -> Properties -> Android -> In Project Build Target check whether checkbox has been selected for Google API only. if not check it. this will add maps.jar in your project and then your project will understand what is MapActivity.. :)

like image 22
Harshad Avatar answered Oct 05 '22 03:10

Harshad