【发布时间】:2018-09-05 05:44:49
【问题描述】:
当我尝试编译我的项目时,我收到了这个奇怪的错误:
What went wrong:
Execution failed for task ':android:transformClassesWithDexBuilderForProdDevelopmentDebug'.
com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: 无法处理 /Users/.../.gradle/caches/ transforms-1/files-1.1/play-services-location-11.2.2.aar/f5b9886774f73d8b64cfd9701f91e8cc/jars/classes.jar
我尝试了什么:
- 已将
multiDexEnabled true添加到应用 gradle。 - 在 gradle.properties 中添加了
android.enableD8.desugaring = true和android.enableD8=true - 还删除了 .gradle 文件夹并进行了重建 + 清理
- 还执行了以下操作:SDK 管理器 -> Google play 服务 -> 更新。之后重建 + 清理。
AS 版本:3.1.4
应用 gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion Android.compileSdkVersion
buildToolsVersion Android.buildToolsVersion
flavorDimensions "...", "type"
defaultConfig {
applicationId "xxx"
versionName 'xxx'
versionCode xxx
minSdkVersion 21
targetSdkVersion Android.targetSdkVersion //Android.targetSdkVersion holds value "27"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "6g"
preDexLibraries = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
test {
dimension "xxx"
applicationIdSuffix '.xxx'
versionNameSuffix 'x'
manifestPlaceholders = [onesignal_app_id : "",
onesignal_google_project_number: ""]
}
production {
dimension "xxx"
manifestPlaceholders = [onesignal_app_id : "",
onesignal_google_project_number: ""]
}
development {
dimension "type"
resConfigs "xxhdpi"
}
normal {
dimension "type"
}
}
android.applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "..."
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/services/javax.annotation.processing.Processor'
exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
exclude 'build-data.properties'
exclude 'error_prone/Annotations.gwt.xml'
exclude 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml'
exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
androidExtensions {
experimental = true
}
}
dependencies {
implementation project(':projectxxx')
implementation project(':tifCompanion')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/YouTubeAndroidPlayerApi.jar')
kapt "android.arch.lifecycle:compiler:1.1.1"
implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "com.android.support.constraint:constraint-layout:1.1.0-beta5"
kapt "com.google.dagger:dagger-compiler:2.16"
api "com.android.support:leanback-v17:27.1.1"
implementation "com.android.support:leanback-v17:27.1.1"
api "com.android.support:recommendation:27.1.1"
implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:support-vector-drawable:27.1.1"
}
实现的projectxxx有以下依赖:
dependencies {
api fileTree(include: ['*.jar'], dir: 'libs')
api project(':JsonAPI') //https://github.com/faogustavo/JSONApi
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.61"
implementation "com.onesignal:OneSignal:3.6.5"
api "com.google.android.gms:play-services-base:15.0.1"
api "com.google.android.gms:play-services-analytics:15.0.0"
api "com.android.support:support-annotations:27.1.1"
}
【问题讨论】:
-
你用过哪个版本的
play-services-location。 -
@FaysalAhmed 15.0.0
-
您是否尝试过:确保您的顶级 build.gradle 包含对 google() 存储库或 maven { url "maven.google.com" } 的引用。
-
是的。结果是一样的。
-
请尝试在 gradle.properties 上添加
android.enableD8=true
标签: android android-gradle-plugin