【问题标题】:Gradle: Unsupported Modules Detected on non-Android projectGradle:在非 Android 项目上检测到不支持的模块
【发布时间】:2019-05-24 09:35:01
【问题描述】:

我在我的 gradle 项目中收到此警告/错误: Unsupported Modules Detected: Compilation is not supported for following modules: io.github.dogo-Dogo, Dogo_main, Dogo_test. Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one project.

我对 Gradle 并不完全熟悉,我搜索了类似的错误,只是在 Android 环境中找到了这些东西,但我只使用了 Kotlin 和一些库。

buildscript {
    ext.kotlin_version = '1.3.11'
    ext.ktor_version = '1.0.1'
    ext.dokka_version = '0.9.17'

    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.dokka:dokka-gradle-plugin:0.9.17"
    }
}

plugins {
    id "org.jetbrains.dokka" version '0.9.17'
}
apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'maven'


group 'io.github.dogo'
version '1.0-SNAPSHOT'



mainClassName = "io.github.dogo.core.boot.BootKt"

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    jcenter()
    maven {url 'https://jitpack.io'}
    maven {
        name = 'sponge'
        url = 'https://repo.spongepowered.org/maven'
    }
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-reflect"
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

    compile "io.ktor:ktor-server-core:$ktor_version"
    compile "io.ktor:ktor-server-netty:$ktor_version"

    compile 'net.dv8tion:JDA:3.8.1_447'
    compile 'org.mongodb:mongodb-driver:3.6.3'
    compile 'org.spongepowered:configurate-json:3.6'
    compile 'com.fasterxml.jackson.core:jackson-databind:2.0.1'
    compile 'com.mashape.unirest:unirest-java:1.3.1'

    compile 'org.slf4j:slf4j-simple:1.6.1'
    compile 'org.apache.logging.log4j:log4j-core:2.11.1'
    compile 'org.apache.logging.log4j:log4j-api:2.11.1'

    compile 'org.jetbrains.kotlin:kotlin-script-runtime:1.3.11'
    compile 'org.jetbrains.kotlin:kotlin-script-util:1.3.11'
    compile 'org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.11'

    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
}

compileKotlin {
    kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
    kotlinOptions.jvmTarget = "1.8"
}

jar {
    manifest {
        attributes 'Main-Class': 'io.github.dogo.core.boot.BootKt'
    }
    from {
        configurations.compile
        .findAll { !it.name.endsWith('pom') }
        .collect { it.isDirectory() ? it : zipTree(it) }
    }
}

dokka {
    outputFormat = 'html'
    outputDirectory = "$buildDir/docs"
}

那么,我该如何解决此错误/警告消息?我不确定,但我认为它是在我添加 Dokka(Kotlin 文档工具)时开始出现的

【问题讨论】:

标签: gradle kotlin kotlin-dokka


【解决方案1】:

Intellij IDEA 的建议修复对我有用 - 适用于纯 Kotlin 工作(不包括任何 Android 跨界工作):

文件 -> 设置 -> 插件 -> 已安装选项卡 -> 取消选中“Android 支持”

日志事件消失了……(h/t Joern Mangels)

https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000404920/comments/360000086479

【讨论】:

    【解决方案2】:

    1- 关闭项目

    2- 关闭 Android Studio IDE

    3- 删除.idea目录

    4- 删除所有 .iml 文件

    5- 打开 Android Studio IDE 并导入项目

    【讨论】:

    • 听起来有点刺耳。构建 » 清洁项目对我有用。
    猜你喜欢
    • 2019-09-25
    • 1970-01-01
    • 2015-04-24
    • 2014-06-24
    • 2014-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-02
    相关资源
    最近更新 更多