无法从Android使用Kotlin ScriptEngine:重复的类

我正在尝试使用Android中ScriptEngine生成的代码,但似乎无法构建我的项目。我一直在尝试和研究如何解决此问题,但似乎无法解决。我将依赖项包含在我的Android Studio项目中的库中。 这是我图书馆的build.gradle.kts:

plugins {
    kotlin("jvm")
    `java-library`
    id("com.jfrog.bintray") version "1.8.4"
}

val kotlinVersion = "1.3.72"

dependencies {
    implementation (fileTree(mapOf("dir" to "libs","include" to listOf("*.jar"))))
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion") {
        //exclude("org.jetbrains.kotlin")
    }

    implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion") {
        exclude("org.jetbrains.kotlin","kotlin-build-common")
        exclude("org.jetbrains.kotlin","kotlin-daemon-client")
    }
    implementation("org.jetbrains.kotlin:kotlin-script-runtime:$kotlinVersion") {
        exclude("org.jetbrains.kotlin","kotlin-daemon-client")
    }
    implementation( "org.jetbrains.kotlin:kotlin-script-util:$kotlinVersion") {
        exclude("org.jetbrains.kotlin","kotlin-build-common")
        //exclude("org.jetbrains.kotlin","kotlin-daemon-client")
    }
    implementation("org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion") {
        exclude("org.jetbrains.kotlin","kotlin-daemon-client")
    }
    implementation("org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:$kotlinVersion") {
        exclude("org.jetbrains.kotlin","kotlin-daemon-client")
    }
    //implementation(kotlin("script-util",kotlinVersion))
    implementation("org.slf4j:slf4j-api:1.7.14")
    implementation("ch.qos.logback:logback-classic:1.1.3")
    implementation("net.java.dev.jna:jna:4.2.2")
}

这是我的应用程序的build.gradle:

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

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationid "com.ignacio.coroutinesamples2"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility = 1.8
        targetcompatibility = 1.8
    }

}

dependencies {
    implementation fileTree(dir: 'libs',include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation (project(":scriptparser"))
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'


    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

每次我进行gradle同步时,它都会显示“ CONFIGURE SUCCESSFUL”,但是当我尝试运行我的项目时,我总是收到相同的长消息:

> Task :scriptparser:compileKotlin UP-TO-DATE
> Task :scriptparser:compileJava NO-SOURCE
> Task :scriptparser:processResources NO-SOURCE
> Task :scriptparser:classes UP-TO-DATE
> Task :scriptparser:inspectClassesForKotlinIC UP-TO-DATE
> Task :scriptparser:jar UP-TO-DATE
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:mainApklistPersistenceDebug UP-TO-DATE
> Task :app:generateDebugResValues UP-TO-DATE
> Task :app:generateDebugResources UP-TO-DATE
> Task :app:mergeDebugResources UP-TO-DATE
> Task :app:createDebugCompatibleScreenmanifests UP-TO-DATE
> Task :app:extractDeepLinksDebug UP-TO-DATE
> Task :app:processDebugManifest UP-TO-DATE
> Task :app:processDebugResources UP-TO-DATE
> Task :app:compileDebugKotlin UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:compileDebugSources UP-TO-DATE
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders UP-TO-DATE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :app:mergeDebugAssets UP-TO-DATE
> Task :app:processDebugJavaRes NO-SOURCE
> Task :app:desugarDebugFileDependencies UP-TO-DATE
> Task :app:checkDebugDuplicateclasses FAILED
> Task :app:mergeDebugJavaResource FAILED

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateclasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: java.lang.RuntimeException: Duplicate class org.jetbrains.kotlin.daemon.common.BoolPropMapper found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.BoolPropMapper$1 found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.BoolPropMapper$2 found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.BoolPropMapper$3 found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.ClientUtilsKt found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.ClientUtilsKt$makePortFromRunFilenameExtractor$1 found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.ClientUtilsKt$walkdaemons$1 found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.ClientUtilsKt$walkdaemons$2 found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)
  Duplicate class org.jetbrains.kotlin.daemon.common.ClientUtilsKt$walkdaemons$3 found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)

  ... this goes on...

  Duplicate class org.jetbrains.kotlin.daemon.common.WallTotalProfiler found in modules jetified-kotlin-daemon-client-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-client:1.3.72) and jetified-kotlin-daemon-embeddable-1.3.72.jar (org.jetbrains.kotlin:kotlin-daemon-embeddable:1.3.72)

如您所见,我尝试对某些依赖项使用“排除”,但是它不起作用。我还评论了一些“排除”,但是如果我不加评论,它们的构建会花费更长的时间,并且我得到以下消息: MethodHandle.invoke and MethodHandle.invokeExact are only supported starting with Android O (--min-api 26)

我可能做错了什么,如果您知道,请告诉我。预先感谢。

yjyyjywww 回答:无法从Android使用Kotlin ScriptEngine:重复的类

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2340821.html

大家都在问