我团队的其他成员正在使用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附带的任何内容),但是我得到其他编译器错误,例如无法从清单中找到它:< / p>
<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')
}
虽然不是理想的解决方案,但我会尽快正确修复属性!
答案 0 :(得分:1)
在Android Studio中,尽可能避免通过库项目或JAR文件包含库。您可以在应用的构建文件中包含map-utils-library和Google Play服务:
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':third_party:facebook-android-sdk-3.17.1:facebook')
compile 'com.google.maps.android:android-maps-utils:0.3+'
compile 'com.google.android.gms:play-services:3+'
}
请注意,这不是Play服务库的最新版本;您应该使用适用于您的应用程序的Eclipse版本以及maps-utils库的任何版本。
此外,最好不要在构建中使用版本号中的+表示法,而是找到明确的版本号并坚持使用。使用+将使构建偶尔到达网络以寻找新版本的库,这可能会给某些开发人员带来问题,并且如果其中一个版本在您下面更新,它可能会使您的构建意外更改和中断。