Developer Console

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

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 Apps-SDK.zip\Android\Maps\2.0\samples\CapitolHillCoffee folder.

There are four separate projects in the CapitolHillCoffee folder, illustrating the CapitolHillCoffee app at different stages:

  • CoffeeActivityDisplay
  • CoffeeActivityLocation
  • CoffeeActivityMarkers
  • CoffeeActivityFinal

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:

  1. On the Android Studio Welcome screen, click Import Non-Android Studio project (or Import Project) and select the sample you want to use.
  2. 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.
  3. In the module-level build.gradle file, under the dependencies section, delete the following line:

    compile project(':amazonmapsapiv2_lib')
    

    This line is added by the import operation.

  4. In File Explorer, navigate to your Android Studio project and delete the amazonmapsapiv2_lib directory. This is the version of the support library that was copied into your project during the import operation.
  5. 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:

  • The package declaration for the .java files in your project
  • The package name specified in the AndroidManifest.xml.

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.

Next Steps

For more details about common Maps API tasks, see:

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.


Last updated: Mar 06, 2017