【发布时间】:2017-11-07 06:01:44
【问题描述】:
我已经开始在 android 中进行 kotlin 编程。我在 android studio 中设置了 kotlin。但是 gradle 无法构建项目。 Kotlin 反射库错误。
这是我的 Logcat:
信息:Gradle 任务 [:app:assembleDebug] 错误:com.android.builder.dexing.DexArchiveBuilderException:失败 过程 C:\Users\USER.gradle\wrapper\dists\gradle-4.1-all\gradle-4.1\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.1.4\27053164a2b459671c4b9fe791408a5bc064937f\kotlin -reflect-1.1.4.jar 错误:com.android.builder.dexing.DexArchiveBuilderException:错误 dexing 时。错误:java.util.NoSuchElementException 错误:执行 任务 ':app:transformClassesWithDexBuilderForDebug' 失败。
com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: 失败 过程 C:\Users\USER.gradle\wrapper\dists\gradle-4.1-all\gradle-4.1\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-reflect\1.1.4\27053164a2b459671c4b9fe791408a5bc064937f\kotlin -reflect-1.1.4.jar 信息:BUILD FAILED in 19s 信息:4 错误信息:0 警告信息:查看控制台中的完整输出
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.1.4'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha01'
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()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'kotlin-android'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.codefuelindia.healthcircleordermgmt"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
postprocessing {
removeUnusedCode false
removeUnusedResources false
obfuscate false
optimizeCode false
proguardFile 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.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'
implementation 'com.android.support:design:26.1.0'
compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
compile 'com.squareup.okhttp3:logging-interceptor:3.8.0'
compile 'com.google.code.gson:gson:2.8.0'
implementation 'com.android.support:cardview-v7:27.0.0'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-reflect:1.1.4"
}
repositories {
mavenCentral()
}
如何解决..需要帮助。
【问题讨论】:
-
发布项目和模块的 gradle 文件
-
这可能是 KOTLIN 配置向导中的一个问题,在较新的插件版本中已修复。更好的是,您可以迁移到适用于 KOTLIN 的 Android Studio 3.0。
-
已经在使用android 3.0
-
您可以在删除 compile "org.jetbrains.kotlin:kotlin-reflect:1.1.4" 和 espresso 和 test:runner 依赖项后尝试同步 gradle 吗?如果您仍然面临问题,请告诉我...请先删除这 3 个依赖项...然后文件-> 使缓存无效并重新启动工作室
-
当我删除“org.jetbrains.kotlin:kotlin-reflect:1.1.4”错误消失但我需要使用“org.jetbrains.kotlin:kotlin-reflect:1.1.4”来获取类名
标签: android android-gradle-plugin kotlin