程序类型已存在:org.intellij.lang.annotations.Flow

26
每当我尝试在Kotlin中运行程序时,都会收到此错误。我的Gradle文件如下:项目级Gradle
buildscript {
    ext.kotlin_version = '1.2.30'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:3.2.0'
    }
}
allprojects {
    repositories {
        google()
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

应用级别的 Gradle

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'
ext.supportLibraryVersion = '27.1.1'
ext.playServices = '11.6.2'
android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.rossa.rossa"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 1
        versionName "1.0.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    repositories {
        jcenter()
        maven { url 'https://jitpack.io' }
        mavenCentral()
        google()
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation"org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
    implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    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:appcompat-v7:$supportLibraryVersion"
    implementation "com.android.support:design:$supportLibraryVersion"
    implementation "com.android.support:cardview-v7:$supportLibraryVersion"
    implementation 'com.jakewharton.timber:timber:4.6.1'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
    implementation 'com.squareup.okhttp3:okhttp:3.9.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.9.0'
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    implementation 'com.appolica:flubber:1.0.1'
    implementation 'org.greenrobot:eventbus:3.1.1'
    implementation 'com.github.daniel-stoneuk:material-about-library:2.2.3-support26.1.0'
}
无论何时我试图运行程序,都会出现以下错误:

Program type already present: org.intellij.lang.annotations.Flow Message{kind=ERROR, text=Program type already present: org.intellij.lang.annotations.Flow, sources=[Unknown source file], tool name=Optional.of(D8)}

4个回答

87
请在您的应用程序级别的 build.gradle 文件中添加以下行。
configurations {
    cleanedAnnotations
    compile.exclude group: 'org.jetbrains' , module:'annotations'
}

3
哇!你怎么会知道这样的事情?你救了我! - Julian A.
我尝试并且成功了,但是我不明白这背后的原因,请简要解释一下问题好吗?谢谢。 - Farshid roohi
对我来说很有效。向你鼓掌1000次。 - Manikandan K
1
我试着给这个答案点赞,但是我不能……因为我一年前已经点过了。 - ElYeante
请问您能否简单解释一下这里发生了什么? - LukeFilewalker

5

排除jetbrains注释模块是一种解决方法;但为什么它会在你的项目中呢?很可能,当你真正想要使用Android自己的注释时,它被Android Studio自动添加到了你的类路径中。

因此,更好的解决方案是在你的build.gradle文件中查找org.jetbrains:annotations依赖项,像这样:

implementation 'org.jetbrains:annotations-java5:15.0'

...并将其删除。


4
对我来说,这只是一个小故障,使用“清理项目”命令就解决了。

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接