importing com.google.maps.MapView not working


Trying to do a map example I found here <a href="http://codemagician.wordpress.com/2010/05/06/android-google-mapview-tutorial-done-right/" rel="nofollow">http://codemagician.wordpress.com/2010/05/06/android-google-mapview-tutorial-done-right/</a>

The problem is this code. Specifically, the compiler does not seem to know what a MapView is? In fact, also applies to android.graphics.drawable.Drawable. I thought that the import statement would resolve that but must be missing some other setup step.

Any help appreciated.

package com.example.HelloGoogleMaps2; import java.util.List; import android.graphics.drawable.Drawable; import android.os.Bundle; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapActivity; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; import com.google.android.maps.OverlayItem; public class MainMap extends MapActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); **MapView** mapView = (MapView) findViewById(R.id.mapview); mapView.setBuiltInZoomControls(true); List<Overlay> mapOverlays = mapView.getOverlays(); **Drawable** drawable = this.getResources().getDrawable(R.drawable.icon); HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable,this); GeoPoint point = new GeoPoint(30443769,-91158458); OverlayItem overlayitem = new OverlayItem(point, "Laissez les bon temps rouler!", "I'm in Louisiana!"); GeoPoint point2 = new GeoPoint(17385812,78480667); OverlayItem overlayitem2 = new OverlayItem(point2, "Namashkaar!", "I'm in Hyderabad, India!"); itemizedoverlay.addOverlay(overlayitem); itemizedoverlay.addOverlay(overlayitem2); mapOverlays.add(itemizedoverlay); } @Override protected boolean isRouteDisplayed() { return false; } }


Check your target device when you create new project. It should be Google APIs(Google Inc.)-API Level -(whatever you want).

as doc says :"you must have an AVD configured to use the Google APIs target, or be using a development device that includes the Maps library".And make sure you have Internet Permission

<uses-permission android:name="android.permission.INTERNET"/>

and as MapView is not included in the default Android libraries, so you need to specify in AndroidManifest.xml

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

and <a href="http://developer.android.com/resources/tutorials/views/hello-mapview.html" rel="nofollow">here</a> is a good place to start with google maps

are you sure you have <img alt="selected google api" class="b-lazy" data-src="https://i.stack.imgur.com/GVNk5.png" data-original="https://i.stack.imgur.com/GVNk5.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />


  • Getting lat long values from database in android
  • Android draw a path on a mapView from a large amount of longitude/latitude points
  • confusion between overlay, overlayitem and itemizedoverley
  • Why using parallel streams in static initializer leads to not stable deadlock
  • Bitmap drawable (Map Overlay Item) pixelizes after rotation in android
  • Line with fill and stroke
  • How concerned should we be about thread safety with JSF managed beans?
  • Youtube Video Player Fullscreen click event
  • C#, “Object reference not set to an instance of an object.” error
  • Change the width of the JQM panels
  • Why isn't \\\\ interpreted as a blackslash in this regex?
  • Cassandra NoClassDefFoundError: com/google/common/util/concurrent/AsyncFunction
  • java.lang.IndexOutOfBoundsException occuring on ArrayList
  • How to Make a Spinner (In a Fragment) That Changes the App's Language?
  • drawing random circles, storing their coorindates in an array
  • Android Database Error - getWriteableDatabase
  • Using Generics on right hand side in Java 6?
  • How to disable all widgets inside Panel or inside Composite?
  • What is the purpose of TaskExecutor in spring?
  • how to find common suffix in java by using method
  • how to avoid repetitive constructor in children
  • Custom Tabgroup Appcelerator
  • Highlight and Bold text in JTextPane
  • NHibernate Validation Localization with S#arp Architecture
  • how to do an event when i swipe from fragment to the other
  • Update CALayer sublayers immediately
  • JFileChooser in front of fullscreen Swing application
  • Akka Routing: Reply's send to router ends up as dead letters
  • Cannot Parse HTML Data Using Android / JSOUP
  • How do you join a server to an Active Directory (domain)?
  • JTable with a ScrollPane misbehaving
  • Understanding cpu registers
  • Java static initializers and reflection
  • Add sale price programmatically to product variations
  • unknown Exception android
  • Observable and ngFor in Angular 2
  • failed to connect to specific WiFi in android programmatically
  • Unable to use reactive element in my shiny app
  • How can I use threading to 'tick' a timer to be accessed by other threads?
  • How do I use LINQ to get all the Items that have a particular SubItem?