【发布时间】:2016-04-19 19:18:43
【问题描述】:
我正在尝试将 microsoft azure 移动服务添加到我现有的 android 应用程序中。在我的文件夹中添加 .jar 文件后。我收到错误:
任务执行失败 ':app:transformClassesWithJarMergingForDebug.
对于annotation.class、Gson$5.class 等各种文件,您可以在错误文件中看到它显示ApiJsonOperationCallback.class。
我已经厌倦了很多东西(例如 ./gradlew clean 和 ./gradlew clean assemble),但到处都遇到了死胡同。
这是我的 gradle 文件
apply plugin: 'com.android.application'
android {compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.jino.navigationplacepicker"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
defaultConfig {
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildscript {
repositories {
jcenter()
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.microsoft.azure:azure-mobile-services-android-sdk:2.0.3'
compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-javadoc.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3-sources.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/gson-2.2.2.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/guava-17.0.jar')
compile files('libs/azuresdk-android-2.0.3/mobileservices/mobileservices-2.0.3.jar')
}
这是错误信息
:app:compileDebugNdk UP-TO-DATE :app:compileDebugSources :app:transformClassesWithJarMergingForDebug 失败错误:执行 任务“:app:transformClassesWithJarMergingForDebug”失败。 com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目: com/microsoft/windowsazure/mobileservices/ApiJsonOperationCallback.class :app:compileDebugJavaWithJavac 注意:一些输入文件使用或覆盖 已弃用的 API。注意:使用 -Xlint:deprecation 重新编译以获取详细信息。 信息:构建失败
请求您对此感到满意,并以外行的方式回应,因为我是新手。
【问题讨论】:
-
如果您是使用 Gradle 构建的新手,那么您可能想read this post,我的答案的附加说明部分解决了您的问题
-
替换:用编译文件('libs/azuresdk-android-2.0.3/mobileservices/gson-2.2.2.jar')编译文件('libs/azuresdk-android-2.0.3/ mobileservices/gson-2.2.2.jar'){ 排除模块:'gson' }
-
我厌倦了,这是我得到的错误“Gradle 同步失败:未找到 Gradle DSL 方法:'exclude()'”。我确实为该问题寻找了解决方案,但没有找到任何解决方案。我的 gradle 版本是 1.5.0 @binaryKarmic
标签: android android-gradle-plugin build.gradle azure-mobile-services