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.
build.gradle
under your own module, under dependencies
element, add compile project(':library')
.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.
To use this way, I tried:
library-debug.aar
in to the libs folder in my module from <library/build/output/aar/ in Android Studio project exploror view.compile fileTree(dir: 'libs', include: ['*.aar'])
into my module build.gradle
file, dependencies
element.Seems that Android studio doesn’t support .aar
type library.
So I changed to the following way:
library-debug.aar
file, and copy the class.jar
file into the libs folder in my module.compile fileTree(dir: 'libs', include: ['*.jar'])
in to my module build.gradle
file, dependencies
element..aar
file, which is not in the class.jar
file. Just guess.