0

I have started kotlin programing in android.I setup the kotlin in android studio.But gradle failed to build project. Kotlin reflection lib error.

Here is my Logcat:

Information:Gradle tasks [:app:assembleDebug] Error:com.android.builder.dexing.DexArchiveBuilderException: Failed to process 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 Error:com.android.builder.dexing.DexArchiveBuilderException: Error while dexing. Error:java.util.NoSuchElementException Error:Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.dexing.DexArchiveBuilderException: com.android.builder.dexing.DexArchiveBuilderException: Failed to process 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 errors Information:0 warnings Information:See complete output in console

// 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()
}

How to solve..Need help.

10
  • Post your gradle files both project and module Commented Nov 7, 2017 at 6:05
  • This may be an issue in KOTLIN configuration wizard that is fixed in newer plugin versions. Better you can move to Android Studio 3.0 for KOTLIN. Commented Nov 7, 2017 at 6:16
  • Already using android 3.0 Commented Nov 7, 2017 at 6:17
  • can u please try to sync gradle after removing compile "org.jetbrains.kotlin:kotlin-reflect:1.1.4" and espresso and test:runner dependency ? let me know if u still face issue...please remove those 3 dependency first..than file-> invalidate cache and restart the studio Commented Nov 7, 2017 at 6:22
  • When I remove "org.jetbrains.kotlin:kotlin-reflect:1.1.4" error gone But I need to use "org.jetbrains.kotlin:kotlin-reflect:1.1.4" for getting classname Commented Nov 7, 2017 at 6:26

1 Answer 1

1

Sync your gradle after Just removing compile "org.jetbrains.kotlin:kotlin-reflect:1.1.4" than file-> invalidate cache and restart option from the studio

For getting classname please refer below link. https://kotlinlang.org/docs/reference/reflection.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.