The rest of my team is using Eclipse and recently the maps were added back into our project. The error I'm getting is that there is a duplicate of the android.gms library, I'm guessing because the google play services and the map-utils-library both feature this package.
Error:Execution failed for task ':projectname:processDebugResources'.
Error: more than one library with package name 'com.google.android.gms' You can temporarily disable this error with android.enforceUniquePackageName=false However, this is temporary and will be enforced in 1.0
Here is my current build.gradle:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':third_party:sdk:extras:google:google_play_services')
compile project(':third_party:facebook-android-sdk-3.17.1:facebook')
compile project(':third_party:android-maps-utils:map-utils-library') }
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('projectname')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
} }
I have tried removing the separate google play services all together (to try and only use whatever comes with the android-maps-utils), but I get other compiler errors such as not being able to locate this from the manifest:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
So what should I do in this situation?
EDIT:
Okay so I've come to the realisation that the answer lies in the build.gradle of the map-utils-library. It featured the following line to bring in the play services:
dependencies {
compile 'com.google.android.gms:play-services:3+'
}
So I figure I should replace that line with my local copy of the play services:
dependencies {
compile project(':third_party:sdk:extras:google:google_play_services')
}
The only problem now I think is that the support library is not integrated properly, I for the moment I've added it like so:
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile project(':third_party:sdk:extras:google:google_play_services')
}
Although not an ideal solution, I will attempt to fix up the properties correctly soon!
In Android Studio, avoid including libraries via library projects or JAR files if at all possible. You can include the map-utils-library and Google Play services via this in your app's build file:
Note that this isn't the latest version of the Play Services library; you should use whatever version works right with the Eclipse build of your app and also the maps-utils library.
Also, it's probably better to not use + notation in version numbers in your builds, but to instead find an explicit version number and stick with that. Using the + will make the build occasionally hit the network to look for new versions of your libraries, which can cause problems for some developers, and it can make your build unexpectedly change and break if one of those versions gets updated underneath you.