How to Use Google Maps Android API Utility Library in Android Studio

Posted in tools with : android, android_studio


Google Maps Android API utility library (the github repo and the documentation) supplies multiple cool features, including

A simple documentation about the usage of these features based on a demo can be found in Google Developers page Google Maps Android API Utility Library. And you can also refer to the javadoc.

When I tried to use the library in my Android Studio (Windows OS) project, I met some problems. It is not as simple as the document describes. A reference for setting up in Eclipse can be found in the Google Maps Android API Utilities Setup.

As we know, we have three ways to use a library in Android Studio project: Module dependency, Remote binary dependency and Local binary dependency. (Go to Configure Gradle Builds for detail). See the following code that we can use in the module build.gradle, not the project build.gradle

dependencies {
    // Module dependency
    compile project(":lib")

    // Remote binary dependency
    compile 'com.android.support:appcompat-v7:19.0.1'

    // Local binary dependency
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

I use the Module dependency method successfully in my project, but failed with the other two methods. Let’s go to the details.

Module Dependency (Succeeded)

Remote Binary Dependency (Failed)

The github page suggested this way by

dependencies {
	compile 'com.google.maps.android:android-maps-utils:x.y.z'
}

But I just can not find the path <Android SDK>/extras/google/m2repository/com/google/map.android/. I am sure that I already installed the Google Repository by SDK manager.

Local Binary Dependency (Failed)

To use this way, I tried:

Seems that Android studio doesn’t support .aar type library.

So I changed to the following way: