Follow the instructions to enable developeroptions on your Android device and configure your application and systemto detect the device.Īlternatively, you can use the Android Emulator to run your app. The simplest way to see your app in action is to connect an Android device toyour computer. If your maps activity file doesn't contain the above code, replace the contentsof the file with the above code, after your package name. MarkerOptions public class MapsActivity extends FragmentActivity implements OnMapRead圜allback Package import import android.os.Bundle import .maps.CameraUpdateFactory import .maps.GoogleMap import .maps.OnMapRead圜allback import .maps.SupportMapFragment import. import .maps.model. It should contain the following code after yourpackage name:
The full process for getting an API key: If neither of the above optionsworks for your situation, see Get an API Key.īy default, the Java file that defines the maps activity is namedMapsActivity.java.Use the copied credentials to add your app to an existing API key or to create a new API key.Go to the Google Cloud Platform Console.Copy the credentials provided in the google_maps_api.xml file.A slightly less fast way: Use the credentials provided in the google_maps_api.xml file that Android Studio created for you:.Copy the resulting API key, go back to Android Studio, and paste the API key into the element in the google_maps_api.xml file.Create an Android-restricted API key for your project.Follow the instructions to create a new project on the Google Cloud Platform Console or select an existing project.
The link takes you to the Google Cloud Platform Console and supplies the required information to the Google Cloud Platform Console via URL parameters, thus reducing the manual input required from you. Copy the link provided in the google_maps_api.xml file and paste it into your browser.The fast, easy way: Use the link provided in the google_maps_api.xml file that Android Studio created for you:.You can use it with any of your applications that call theMaps SDK for Android, and it supports an unlimited number of users.Ĭhoose one of the following ways to get your API key from Android Studio:
The type ofkey you need is an API key with restriction for Android apps. Your application needs an API key to access the Google Maps servers.
The next sectiondescribes getting the API key in more detail. (Note that your activity may havea different name, but it will be the one you configured during setup.) Noticethat the google_maps_api.xml file contains instructions on getting aGoogle Maps API key before you try to run the application. When the build is finished, Android Studio opens the google_maps_api.xml andthe MapsActivity.java files in the editor. For more information about creating a project in Android Studio,see the Android Studio documentation. Select Google Maps Activity, then click Next.Įnter your app name, package name, and project location, programming language (Java or Kotlin), and the minimum Android API level supported by your app, then click Finish.Īndroid Studio starts Gradle and builds your project. Most users will want to keep the default Phone and Tablet. In the Choose your project dialog, select the tab that corresponds to the platform you intended to develop for. Otherwise, click File in the Android Studio menu bar, then New, New Project.If you see the Welcome to Android Studio dialog, choose Start a newAndroid Studio project, available under 'Quick Start' on the right ofthe dialog.Download Android Studioįollow the guides to download and installAndroid Studio. AndroidStudio is the recommended development environment for buildingan app with the Maps SDK for Android. This guide is a quick start to adding a map to an Android app. Get Started | Maps SDK for Android | Google Developers