Migrating an App from Google Maps v2

Introduction

The Amazon Maps API provides mapping functionality for Android apps on Fire tablets and Fire phone. If your app uses Google Maps, you can migrate your app to the Amazon Maps API by making some minor code changes and then re-compiling your app against the Amazon Maps API. You can then run your app on Fire phone and Fire tablet devices and distribute your app in the Amazon Appstore for Android.

The Amazon Maps API offers interface parity with version 2 of the Google Maps API. Most classes and method calls in your Google Maps app work the same on Amazon devices. For information about the differences, see Differences between Amazon Maps and Google Maps.

Steps to Migrate Your App

Note: Before you begin, you may want to consider whether you can use your build system to automate this process so that you can produce both Google–compatible and Amazon–compatible APKs from the same source code.

Renaming Namespaces and Classes

The following table lists the Google–specific namespaces and classes that you must rename to the Amazon versions. You may find it useful to use find and replace tools in your IDE to make these updates.

Google Name

Amazon Name

com.google.android.gms.maps

com.amazon.geo.mapsv2

com.google.android.gms.common.GooglePlayServicesUtil

com.amazon.geo.mapsv2.util.AmazonMapsRuntimeUtil

GoogleMap

AmazonMap

GoogleMapOptions

AmazonMapOptions

GooglePlayServicesUtil.isGoogleSignedUid

AmazonMapsRuntimeUtil.isAmazonSignedUid

Renaming XML Attributes

A Google Maps–compatible app can use custom XML attributes in a layout XML file to set initial map options. For example, you can specify map:mapType="satellite" to set the initial map type to satellite.

The Amazon Maps API supports the same set of XML attributes, but they are named with an amzn_ prefix. If you are using the XML attributes in your app, you need to rename them with the Amazon versions.

Testing Your Migrated App

When testing your migrated app on an Amazon device, pay special attention to any areas where you used features that are not supported in the Amazon Maps API. You can turn on strict mode to help find these areas. Strict mode causes the methods used for these features to log warnings or throw exceptions instead of silently failing.