我团队的其他成员正在使用 Eclipse,最近这些地图又重新添加到了我们的项目中。我得到的错误是 android.gms 库的副本,我猜是因为 google play 服务和 map-utils-library 都具有这个包。
错误:任务 ':projectname:processDebugResources' 执行失败。
错误:多个库的包名称为 'com.google.android.gms' 您可以使用 android.enforceUniquePackageName=false 暂时禁用此错误 但是,这是暂时的,将在 1.0 中强制执行
这是我当前的 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')
} }
我已经尝试一起删除单独的 google play 服务(尝试并且只使用 android-maps-utils 附带的任何内容),但我得到了其他编译器错误,例如无法从清单中找到它:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
那么在这种情况下我该怎么办呢?
编辑:
好的,所以我意识到答案在于 map-utils-library 的 build.gradle。它具有以下特色以引入播放服务:
dependencies {
compile 'com.google.android.gms:play-services:3+'
}
所以我想我应该用我的本地播放服务副本替换那行:
dependencies {
compile project(':third_party:sdk:extras:google:google_play_services')
}
现在我认为唯一的问题是支持库没有正确集成,我现在添加它是这样的:
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile project(':third_party:sdk:extras:google:google_play_services')
}
虽然不是一个理想的解决方案,但我会尽快尝试正确修复这些属性!