Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Java和Kotlin结合构建错误(重复Zip条目)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

我已将Kotlin库添加到现有项目中.之后我得到了构建错误.我评论了最近添加的所有库,并检查了添加kotlin库后的主要问题

Error:Execution Failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [/home/imedrix-server/studioProjects/kardioscreen-operatorapp/app/build/intermediates/multi-dex/debug/componentClasses.jar] (Can't read [/home/imedrix-server/studioProjects/kardioscreen-operatorapp/app/build/intermediates/transforms/desugar/debug/76.jar(;;;;;;**.class)] (Duplicate zip entry [76.jar:org/intellij/lang/Annotations/Flow.class]))

项目gradle

buildscript {
    ext.kotlin_version = '1.2.21'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath ('com.google.firebase:firebase-plugins:1.0.5') {
            exclude group: 'com.google.guava',module: 'guava-jdk5'
        }
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {url "https://maven.google.com"}
    }
}

而应用程序是gradle

apply plugin: 'com.android.application'

apply plugin: 'com.google.firebase.firebase-crash'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

apply plugin: 'kotlin-kapt'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId 'com.example.android'
        minSdkVersion 20
        targetSdkVersion 27
        versionCode 17
        versionName "1.0"
        multiDexEnabled true
        vectorDrawableS.UseSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
//            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
        debug {
            buildConfigField("String","BASE_URL","\"url\"")
            buildConfigField("String","API_KEY","\"key\"")
        }
    }

    productFlavors {
    }
    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "4g"
    }

    compiLeoptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    packagingOptions {
        exclude 'Meta-INF/LICENSE.txt'
        exclude 'Meta-INF/NOTICE.txt'
        exclude '.readme'
    }
}



dependencies {
    compile fileTree(include: ['*.jar'],dir: 'libs')
    compile project(':controllers')
    compile files('libs/achartENGIne-1.2.0.jar')
    compile files('libs/dfuLibrary.jar')
    compile 'com.android.support:appcompat-v7:27.0.2'
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    compile 'com.android.support:design:27.0.2'
    compile 'com.android.support:recyclerview-v7:27.0.2'
    compile 'com.android.support:cardview-v7:27.0.2'
    compile 'com.polidea.rxandroidble:rxandroidble:1.0.2'
    compile 'com.google.firebase:firebase-crash:11.8.0'
    compile 'com.android.support.consTraint:consTraint-layout:1.1.0-beta4'
    compile 'com.android.support:support-v4:27.0.2'
    compile 'com.google.android.gms:play-services-LOCATIOn:11.8.0'
    compile 'com.jakewharton:butterknife:8.8.1'
    TESTCompile 'junit:junit:4.12'
    /*compile 'org.hashids:hashids:1.0.3'
        compile 'com.google.dagger:dagger:2.11'
        compile 'javax.inject:javax.inject:1'
        kapt 'com.google.dagger:dagger-compiler:2.11'
        compile 'io.reactivex.rxjava2:rxjava:2.1.3'
        compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
        kapt 'com.jakewharton:butterknife-compiler:8.8.1'
        compile 'com.amitshekhar.android:rx2-android-networking:1.0.0'
        compile 'com.android.support:multidex:1.0.2'*/
}

apply plugin: 'com.google.gms.google-services'

如果我从应用程序gradle中删除以下行,一切正常.但是如果我添加kotlin库我就会收到错误.

compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

我如何一起使用kotlin和Java.

最佳答案
Atlast我找到了答案,这是由于重复输入注释,可以通过使用gradle中的以下行来解决.

configurations {
        compile.exclude group : 'org.jetbrains',module : 'Annotations'
}

大佬总结

以上是大佬教程为你收集整理的Java和Kotlin结合构建错误(重复Zip条目)全部内容,希望文章能够帮你解决Java和Kotlin结合构建错误(重复Zip条目)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。