Using the Sample App (v2.0 - Deprecated)
The Amazon Maps API includes a basic sample app that illustrates a simple app for displaying coffee shops on a map.
Before importing the sample code into your IDE, be sure to set up your development environment. See Getting Started with Android Studio for information about setting up the Android Studio development environment.
- Downloading the Sample App
- Importing the Sample Code
- Compiling and Running the Sample
- Next Steps
Downloading the Sample App
The CapitolHillCoffee sample is part of the Apps & Games Services SDKs. To get the sample, download the Maps API from the SDK Downloads page and extract the files. In this case, the sample is in the
There are four separate projects in the
CapitolHillCoffee folder, illustrating the CapitolHillCoffee app at different stages:
Importing the Sample Code
You can import the sample projects into an IDE such as Android Studio.
Importing the Sample Code into Android Studio
When using Android Studio, use the Import Non-Android Studio project from the Welcome screen (called Import Project in pre-1.0 versions). By default, this copies the project to your default location for Android projects.
This also imports the project's dependencies, but we recommend updating your project to reference the Amazon Maps API Support Library in a local Maven repository instead:
- On the Android Studio Welcome screen, click Import Non-Android Studio project (or Import Project) and select the sample you want to use.
- Once the project is imported, follow the instructions in Configuring Your Project to Use the Amazon Maps API v2 to do the following:
- Install the support library to a local Maven repository if not already done.
- Update the sample project dependencies to use the Maven reference.
In the module-level
build.gradlefile, under the
dependenciessection, delete the following line:
This line is added by the import operation.
- In File Explorer, navigate to your Android Studio project and delete the
amazonmapsapiv2_libdirectory. This is the version of the support library that was copied into your project during the import operation.
- At the top of the editor, in the yellow alert indicating that Gradle files have changed, click Sync Now.
Compiling and Running the Sample
Before you can run the sample, you need to register it with the Amazon Apps & Games Developer Portal. This provides the app access to map tiles.
The package name for the sample is
com.example.amazon.capitolhillcoffee. You should change this to your own package name before registering the app. Be sure to update the package name in all the places it appears in the project:
packagedeclaration for the
.javafiles in your project
- The package name specified in the
After changing the package name, follow the instructions in Registering and Testing Your Amazon Maps API v2 App to register the debug version of the sample app with the Amazon Apps & Games Developer Portal. You can then test the app on an Amazon device.
For more details about common Maps API tasks, see:
- Displaying an Interactive Map with the Amazon Maps API v2
- Drawing Markers and Objects on the Map with the Amazon Maps API v2
For information on setting up your project to use the Amazon Maps API, see Configuring Your Project to use the Amazon Maps API v2.
For information about migrating your app from Google Maps, see Migrating an App from Google Maps v2.
For information about registering your app so you can display map tiles, as well as testing guidelines, see Registering and Testing Your Amazon Maps API v2 App.
For a reference to the API, see the Amazon Maps API v2 Reference.
For additional help and information, see the Amazon Maps API Frequently Asked Questions.