Google Maps Platform 推出 15 周年 - 查看最新资讯和公告

Installing Maps SDK for Android v.3.1.0 BETA

This guide shows you how to install the Maps SDK for Android v.3.1.0 BETA. Once you're set up, learn how to use the new features.

Install the Maps SDK for Android v3.1.0 BETA

Follow these steps to manually add the v3.1.0 Beta Maps SDK for Android client library to your Android Studio project.

  1. Download the Places static library (you can skip this step if not using Places):

  2. Copy the AAR file into the app/libs folder of your Android Studio project.
  3. The Maps SDK for Android library is available through Google's Maven repository. To add the SDK to your app, do the following:

  4. In the buildscript.repositories section of your top-level build.gradle file, make sure Google's Maven repo is listed:

    buildscript {
        repositories {
            google()
            // ...
        }
    }
  5. In the dependencies section of your app-level build.gradle file, add the Maps SDK for Android, and optionally, the Places static library and its required dependencies:

    dependencies {
      implementation 'com.google.android.libraries.maps:maps:3.1.0-beta'
    
      // If you are using Places, add all of the dependencies below
      implementation name:'places-maps-sdk-3.1.0-beta', ext:'aar'
      implementation 'com.google.android.gms:play-services-gcm:17.0.0'
      implementation 'com.google.auto.value:auto-value-annotations:1.6.2'
    }
  6. In the dependencies section of your app-level build.gradle file, remove the implementation line for the previous version (it will appear similar to the following):

  7. implementation 'com.google.android.gms:play-services-maps:17.0.0'

    If you are using the Google Maps Platform Premium Plan, the implementation line to remove looks like one of the following:

    implementation(name:'google-maps-sdk-m4b', ext:'aar')
    implementation project(':googlemapssdkm4b_lib')
    
  8. Sync your Gradle project.
  9. Convert existing configurations.

    • If your existing app uses the Maps SDK for Android via Google Play services, replace all references to the com.google.android.gms.maps package with the com.google.android.libraries.maps package (use Edit > Replace in Path... in Android Studio).
    • If your existing app uses the Google Maps Platform Premium Plan, replace all references to the com.google.android.m4b.maps package with the com.google.android.libraries.maps package. Also, remove the m4b_ prefix from all references to the XML layout attributes. For example: m4b_mapType should become mapType and m4b_cameraZoom should become cameraZoom.

Import the beta-compatible utility library

If you are using the Google Maps Android API utility library, you will need to also update your project dependencies to replace the existing version with the beta-compatible version by doing the following:

  1. Import the beta-compatible util library in your build.gradle file:
    implementation 'com.google.maps.android:android-maps-utils-v3:1.3.1'
    
  2. Remove the following from your build.gradle to remove non-beta-compatible utility library:
    implementation 'com.google.maps.android:android-maps-utils:1.3.1'
    

Run the samples

The Google Samples repository on GitHub includes sample apps that demonstrate the use of the v3.1.0 Beta Maps SDK for Android.