我团队的其他成员正在使用Eclipse,最近将映射添加到我们的项目中。我遇到的错误是android.gms库有一个副本,我猜是因为google服务和map-utils库都有这个包的特性。
错误:任务执行失败“: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服务全部删除(只尝试使用android-maps utils附带的任何功能),但我得到了其他编译器错误,比如无法从清单中找到该服务:
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />那么在这种情况下我该怎么办呢?
编辑:
好的,我已经意识到答案在于地图-用例库的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')
}虽然不是一个理想的解决方案,但我很快就会尝试正确地修复这些属性!
发布于 2014-08-18 13:43:50
在Android中,尽可能避免通过库项目或JAR文件包括库。您可以在应用程序的构建文件中包括map-utils-库和Google服务:
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 Services库的最新版本;您应该使用与应用程序的Eclipse构建和地图-utils库相匹配的任何版本。
另外,在构建中最好不要在版本号中使用+符号,而应该找到一个显式的版本号并坚持使用。使用+会使构建偶尔击中网络以查找库的新版本,这可能会给一些开发人员带来问题,如果在您下面更新其中一个版本,它可能会使您的构建发生意外的更改和中断。
https://stackoverflow.com/questions/25362975
复制相似问题