Developer Console
Thank you for your visit. This page is only available in English at this time.

Using the Sample App (v2.5)

The Amazon Maps SDK includes a sample app called CapitolHillCoffee that illustrates how to display coffee shops on a map.

Downloading the Sample App

The CapitolHillCoffee sample app is part of the Maps SDK Download. After you extract the zip file, the sample app is in the examples\CapitolHillCoffee folder.

The app has four separate projects in the CapitolHillCoffee folder, illustrating the CapitolHillCoffee app at different stages:

  • step1_display_map - Display Amazon map view
  • step2_add_my_location - Move to user's current location on the map.
  • step3_add_coffee_markers - Add markers for coffee shops
  • step4_final - Final step

Importing the Sample Code into Android Studio

To open the sample app in Android Studio:

  1. Start Android Studio and select Open an existing android studio project at the startup dialog.
  2. Browse to one of the projects described in the previous section (e.g., step1_display_map). Select the build.gradle file under the project step you want to load, and then click Open.
  3. If you're prompted about a Gradle Sync error, click OK.

By default, your project is copied to your default location for Android projects and the projects dependencies are imported.

Add the Amazon Maps SDK Library

You need to add the Amazon Maps SDK library to your project, if you haven't already. Detailed steps for this are provided in Step 3: Configure Your Project in Android Studio.

Compile and Run the Sample App

Before you can run the sample app, you need to register it with the developer portal. Registration will provide 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, since all packages in the Amazon developer portal must have unique names. 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.

To customize the package name:

  1. Make sure you're in the Android view.
  2. Click the Options menu (gear icon).
  3. Expand the java folders (java > com > examples > amazon > capitolhillcoffee).
  4. Right click example and select Refactor > Rename.
  5. Select a unique name (such as your name) and then click Refactor.
  6. Click Do Refactor.
  7. Make sure the package names have been changed in your AndroidManifest, build.gradle files, and any other places.
  8. Go to Build > Rebuild Project.

Register Your App

Follow the steps in Register and Test Your Maps App (v2.5). This registration is required in order to access the map tiles.

Next Steps

For more details about common Maps API tasks, see the following: