简体   繁体   中英

Using Google Maps in Android - Error code

i was trying to learn this tutorial. Using Google Maps in Android- http://mobiforge.com/developing/story/using-google-maps-android

The first code that I did is :

package net.learn2develop.GoogleMaps;

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

    public class MapsActivity 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() {
            return false;
        }
    }

Im getting a lot of error such as:

1) import.com.google cannot be resolved. 2) MapActivity cannot be resolved to a type.

Please help me. Thanks

OK. I FOUND THE SOLUTION IN Mapview in MapActivity Class not found

You are using the old/deprecated API which cannot be used now . You Have to use the Google Maps V2 Api for development. For this you need

  1. Google Play services install in your SDK( Read this Post ).
  2. API key from the Google API Console.
  3. If you want to develop for android 2.2 (Froyo) and above you need to use the Supportmapfragment and fragmentActivity( Read This Post ).
  4. If you want to develop for android 3.0(honeycomb) and above you have to use the Mapfragment and the Activity( Read This Post ).

Please Search the SO forum before posting a question there are a lot of solved Questions regarding the Same Issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM