views:

1843

answers:

6

Right.

So I have an app widget.

It has 4 buttons, one one of the buttons I want it to show me the current location of the user on the map.

So - I make a new activity as below:

package com.android.driverwidget;

import java.util.List;

import android.os.Bundle;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;



public class MyLocation extends MapActivity{



     public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.main);

    MapView myMapView = (MapView)findViewById(R.id.mapview);
    MapController mapController = myMapView.getController();

    List<Overlay> overlays = myMapView.getOverlays();
    MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this,             myMapView);
    overlays.add(myLocationOverlay);
    myLocationOverlay.enableMyLocation();
  }


    protected boolean isRouteDisplayed() {

      return false;
    }




}

And then I added the appropriate uses library line to the manifest

<activity android:name=".MyLocation"
    android:label="myLocation">
     </activity>

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

Ok yet - when I run the app the following errors occur, looks like it cannot find the MapActivity class, im running it on the GoogleApps 1.5 instead of normal android 1.5 as well.

http://pastebin.com/m3ee8dba2

Somebody plz help me - i am now dying.

A: 

If you look a few lines before you start getting verify errors you'll see this line:

07-20 14:40:03.460: WARN/dalvikvm(753): Unable to resolve superclass of Lcom/android/driverwidget/MyLocation; (61)

This is what's causing the problem. The most likely cause is that there's an error in your manifest file where it's including the Maps library. If you post your whole manifest I'll try to help further.

fiXedd
wow ok sure:this is my manifest : http://pastebin.com/me5a80c1
Ok, based on that I'm stumped as I can't reproduce it on my end. I think the next thing I'd do is to go at the manifest file with a different editor and make sure that no errant unicode characters snuck in (I've had this happen when copy/pasting from the web). Look especially around the <uses-library /> bit. One way or another it isn't making use of the com.google.android.maps library.
fiXedd
which editor under windows do you suggest!?
A: 

You're problem might be related to this bug:

http://groups.google.com/group/android-developers/msg/904fae350cda3ebc

miracle2k
hmmm yeah possibly i guess it could be - think its fixed with 1.5 _r3?
A: 

Any help to this is greatly appreciated!!

Ram
A: 

When you creating this project you have to choose Google APIs project not only AVD.

+2  A: 

Fix your manifest by adding/moving

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

into application.

digitarald
thank-you, this was helpful.
BPerreault
Thank you, you just made my day :)
Linus Unnebäck
A: 

Place this line in the tag and outside the tag. This line is usually put before the tag.

L0rDKadaj