Kotlin配置错误

我已经开始在Android的Kotlin编程。我在android studio中设置kotlin。但是gradle无法构建项目。 Kotlin反射lib错误。

这是我的Logcat:

信息:Gradle tasks [:app:assembleDebug]错误:com.android.builder.dexing.DexArchiveBuilderException:无法处理C:\ Users \ USER.gradle \ wrapper \ dists \ gradle-4.1-all \ gradle-4.1 \ caches \ kimlin-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 Information:BUILD FAILED in 19s Information :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() } 

如何解决..需要帮助。

在删除编译“org.jetbrains.kotlin:kotlin-reflect:1.1.4”之后,同步你的gradle而不是file->从studio中取消缓存和重启选项

获取classname请参考下面的链接。 https://kotlinlang.org/docs/reference/reflection.html