【发布时间】:2018-05-26 12:42:27
【问题描述】:
我的项目在 Android Studio 3.0.1 上的 Kotlin 这是我的设计等级
buildscript {
ext.kotlin_version = '1.2.0'
ext.anko_version='0.10.3'
repositories {
jcenter()
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
在这个应用程序中我正在创建一个库,在这个库中我有以下渐变文件。
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.google.code.findbugs'
}
implementation('com.google.apis:google-api-services-gmail:v1-rev66-1.22.0') {
exclude group: 'org.apache.httpcomponents'
}
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
testImplementation 'com.greghaskins:spectrum:1.2.0'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
implementation 'com.google.code.gson:gson:2.8.0'
implementation 'io.reactivex.rxjava2:rxjava:2.0.2'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation 'com.android.support:multidex:1.0.2'
implementation 'com.google.android.gms:play-services-location:11.6.2'
implementation 'com.google.android.gms:play-services-gcm:11.6.2'
implementation 'com.google.android.gms:play-services-auth:11.6.2'
}
apply plugin: 'com.google.gms.google-services'
到目前为止一切顺利,项目编译正常,但是当我去构建时,通过手机上的usb运行应用程序出现以下错误,我仍然无法解决。
错误:任务执行失败:应用程序: transformDexArchiveWithExternalLibsDexMergerForDebug'。
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: 无法合并 索引
提前感谢您的帮助。
【问题讨论】:
-
这是整个错误信息吗?在“Gradle 控制台”视图中,应该有更多信息 - 例如,在 stackoverflow.com/q/46053902/3934789 的情况下,同一类有多个副本。
-
gradle 控制台上写的是这里:
FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ': app: transformDexArchiveWithExternalLibsDexMergerForDebug'. > java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 39s 38 actionable tasks: 19 executed, 19 up-to-date -
嗯。该消息中的
--stacktrace是否可点击?这应该迫使它重新运行有关错误的更多信息。你也可以打开终端并运行gradlew assembleDebug --stacktrace(如果你在Windows上)或./gradlew assembleDebug --stacktrace(如果你在其他任何东西上)。如果您通过这种方式获得更多信息,请将其添加到您的问题中,以便我更轻松地阅读。
标签: android android-studio kotlin google-play-services build.gradle