2
    :app:mergeDebugAssets
            :app:processDebugJavaRes UP-TO-DATE
            :app:transformResourcesWithMergeJavaResForDebug FAILED

            FAILURE: Build failed with an exception.

            * What went wrong:
            Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
            > com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK kotlin/internal/internal.kotlin_builtins
            File1: /Users/KD/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.0.4/172b43fbc03b521fed141484b212d6725fa671a9/kotlin-compiler-embeddable-1.0.4.jar
            File2: /Users/KD/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-runtime/1.0.4/8e25da5e31669f5acf514bdd99b94ff5c7003b3b/kotlin-runtime-1.0.4.jar

My build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.app2par.ctime"
        minSdkVersion 16
//        minSdkVersion 21
//        targetSdkVersion 23
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        multiDexEnabled false
//        multiDexEnabled true
    }
    dexOptions {
        preDexLibraries true
        javaMaxHeapSize "2g" // Use gig increments depending on needs
        incremental true
    }
    buildTypes {
        debug {
            minifyEnabled false
//            testCoverageEnabled true
//            ext.betaDistributionReleaseNotes = getCrashlyticsBetaMessage()
//            ext.betaDistributionGroupAliases = 'team'
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }
//    dataBinding {
//        enabled = true
// https://code.google.com/p/android/issues/detail?id=187443&q=attachments%3D0&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars
//    }
    lintOptions {
        abortOnError false
    }

    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':firebasesync')
    compile project(':liboid')
    compile project(':cloudtimemodel')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.1') {
        exclude group: 'com.android.support'
    }
    androidTestCompile('com.android.support.test.espresso:espresso-contrib:2.2.1') {
        exclude group: 'com.android.support'
    }
    compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    //    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    //        transitive = true;
    //    }
    //    compile 'com.google.android.gms:play-services:5.0.89'
    //    compile 'com.google.android.gms:play-services:7.0.0'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
    // compile   'com.firebase:firebase-client-android:2.0.3.+'
//    compile 'com.google.android.gms:play-services-safetynet:8.3.0'
//    compile 'com.google.android.gms:play-services-auth:8.3.0'

    compile 'com.google.android.gms:play-services-plus:7.0.0' // play-services-plus:7.0.0 : office-mover
//    compile 'com.google.android.gms:play-services-auth:8.3.0' // play-services-auth:8.3.0 : ShoppingList++

    //    compile 'com.google.android.gms:play-services-identity:7.0.0'
}
buildscript {
//    ext.kotlin_version = '1.0.0-rc-1036'
    ext.kotlin_version = '1.0.4'
    repositories {
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//        classpath 'org.ajoberstar:grgit:1.1.0'
//        classpath 'io.fabric.tools:gradle:1.+'
//        classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.5.0-x'
    }
}
repositories {
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
}

How to fix or diagnose this?

3 Answers 3

2

You should remove compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" from your dependencies section and move it to buildscript { dependencies { ... } }.

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

Comments

2

You did put compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" in the wrong build.gradle file

You may use kotlin plugin's build-in converters to deal with this. According to Kotlin Docs:

Configuring Kotlin in the project

When adding a new Kotlin file, IntelliJ IDEA (and Android Studio) automatically prompts us as to whether we'd like to configure the Kotlin runtime for the project. However, currently, converting existing Java file does not prompt this action. Therefore we have to invoke it manually (via Find Action):

Config-Kotlin

We are then prompted for the version of Kotlin. Choose the latest available from the list of installed versions.

Config-Kotlin-Details

After we configure Kotlin, build.gradle file for the application should be updated. Now we can see that apply plugin: 'kotlin-android' and the dependencies were added.

(For more details how to set up gradle for your project, please check Using Gradle)

The last thing to do is to sync the project. We can press Sync Now in a prompt or invoke an action Sync Project with Gradle Files.

https://kotlinlang.org/assets/images/tutorials/kotlin-android/sync-project-with-gradle.png

From: https://kotlinlang.org/docs/tutorials/kotlin-android.html

Check link above for more information.

Hope it will help.

Comments

0

you need to apply only one plugin, in your case apply plugin: 'kotlin-android-extensions' and only compile "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version" this dependency. it worked for me

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.