Problem mit MapActivity

D

Daya

Ambitioniertes Mitglied
5
Gelöst: Für alle mit dem selben Problem. Man sollte auch das google sdk und nicht das android nutzen :-(

Hi,

ich probiere mich gerade am diesem Maps Tutorial:Google Map View | Android Developers

aber schon bei Punkt 6 meckert mein Eclipse, das es die MapActivity Class nicht gibt.

Code:
package test.hellp.maps;

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

public class HelloGoogleMaps extends MapActivity  {
    /** Called when the activity is first created. */
    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapView.setBuiltInZoomControls(true);
    }
}
Dann steht in der Zeile in der ich die Classe definiere das rote X mit dem Vorschlag Create Class MapActivity.

Jemand eine Idee was ich falsch mache? Habe hier im Forum nur einen Beitrag zu MapActivity gefunden und der hatte ein Problem mit dem Api Key
 
Zuletzt bearbeitet:
Hab das gleiche Problem im Moment. Kenne das Problem, aber leider nicht die Lösung. Das Problem ist das er import com.google.android.maps.MapActivity;
nicht importieren kann. Ich selbst hab alle GoogleApi AVD-Addons installiert und auch die sonstigen Schritte durchgeführt. Leider bisher ohne Erfolg. Wäre um Hinweise dankbar.
 
Benutzt du Eclipse?

After installing the Google APIs add-on in your SDK, set your project properties to use the build target called "Google APIs by Google Inc.". See the instructions for setting a build target in Developing in Eclipse with ADT or Developing in Other IDEs, as appropriate for your environment.

Das richtige BuildingTarget gewählt?
 
Zuletzt bearbeitet:
  • Danke
Reaktionen: crush3r
Wo stellt man das ein?
Habe ein ähnliches Problem. Bei mir sagt LogCat:

Package ... requires unavailable shared library com.google.android.maps; failing!

--> Problem gefunden^^
 
Zuletzt bearbeitet:
Hallo

Ich hab ein ähnliches Problem.

package com.mapview;

import com.google.android.maps.MapActivity;
import android.os.Bundle;
import android.widget.LinearLayout;

public class MapView extends MapActivity {

LinearLayout linearLayout;
MapView mapView;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
linearLayout = (LinearLayout) findViewById(R.id.mainlayout);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);


}

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

}
er sagt mir immer cannot cast View to MapView.

so sieht meine main.xml aus

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="KEY"
/>

<LinearLayout
android:id="@+id/zoomview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/mapview"
android:layout_centerHorizontal="true"
/>


</RelativeLayout>
Hab jetzt die 4. Seite bei google umgeblättert, aber ich finddie Lösung nicht, obwohl da Problem mehrere haben.


Hab alles nochmal neu gemacht und die Activity anders genannt ... jetzt hat er keine Probleme mehr mit dem umcasten, allerdings meldet mir mein Handy jetzt: "Tut uns Leid Die Anwendung MapTest wurde unerwartet beendet."

Hier mal meine HelloMapView.java
package com.map;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;

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

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

// MapView mapView = (MapView) findViewById(R.id.mapview);
// mapView.setBuiltInZoomControls(true);

}

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

hat irgendwer ne Idee ??
 
Zuletzt bearbeitet:
ok sorry ...

Ich hatte die

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

innerhalb des <activity> anstatt nur der <application> in der main.xml stehen.
 

Ähnliche Themen

S
Antworten
4
Aufrufe
993
Sempervivum
S
B
Antworten
4
Aufrufe
486
bb321
B
R
Antworten
3
Aufrufe
1.618
Ritartet
R
Zurück
Oben Unten