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
- Importing the Sample Code into Android Studio
- Add the Amazon Maps SDK Library
- Compile and Run the Sample App
- Register Your App
- Next Steps
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
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:
- Start Android Studio and select Open an existing android studio project at the startup dialog.
- Browse to one of the projects described in the previous section (e.g., step1_display_map). Select the
build.gradlefile under the project step you want to load, and then click Open.
- 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:
packagedeclaration for the
.javafiles in your project
- The package name specified in the
To customize the package name:
- Make sure you're in the Android view.
- Click the Options menu (gear icon).
- Expand the java folders (java > com > examples > amazon > capitolhillcoffee).
- Right click example and select Refactor > Rename.
- Select a unique name (such as your name) and then click Refactor.
- Click Do Refactor.
- Make sure the package names have been changed in your AndroidManifest, build.gradle files, and any other places.
- 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.
For more details about common Maps API tasks, see the following: