'java'插件已应用,但与Android插件不兼容

The 'java' plugin has been applied, but it is not compatible with the Android plugins

我在尝试将 Fabric 集成到我的 Android 应用程序的 Gradle 文件中时遇到以下错误。

Error:The 'java' plugin has been applied, but it is not compatible with the Android plugins.

我的 Gradle 文件如下所示:

apply plugin: 'com.android.application'
// Put Fabric plugin after Android plugin
apply plugin: 'io.fabric'

repositories {
    mavenLocal()
    flatDir {
        dirs 'libs'
    }
    maven { url 'https://maven.fabric.io/public' }
}

android {
    compileSdkVersion 24
    buildToolsVersion '25.0.0'

    defaultConfig {
        applicationId "com.snapwebdevelopment.scanhappy"
        minSdkVersion 19
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    // Displaying images
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile 'com.firebaseui:firebase-ui-auth:1.0.1'
    compile 'com.firebaseui:firebase-ui-storage:0.6.0'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.google.firebase:firebase-storage:10.0.1'
    compile 'com.google.firebase:firebase-database:10.0.1'
    compile 'com.google.firebase:firebase-auth:10.0.1'
    compile 'me.dm7.barcodescanner:zxing:1.9'
    compile 'com.google.android.gms:play-services-vision:10.0.1'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'me.anwarshahriar:calligrapher:1.0'
    testCompile 'junit:junit:4.12'
    compile 'com.stripe:stripe-android:2.0.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.braintreepayments:card-form:3.0.3'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.6@aar') {
        transitive = true;
    }

    compile files('libs/org-apache-commons-codec.jar')
}


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

还有我的顶级 gradle 文件:

buildscript {
    repositories {
        jcenter()
        mavenLocal()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'com.google.gms:google-services:3.0.0'
        classpath 'io.fabric.tools:gradle:1.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenLocal()
        maven { url 'https://maven.fabric.io/public' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

我还在 </application> 标签前右下角的清单中添加了 API 密钥。我需要重新排序 Gradle 文件中的内容吗?

您不能在同一模块中同时应用 com.android.applicationjava 插件。

删除带有apply plugin: 'java'

的行
         buildscript {
          repositories {
    maven { url 'https://maven.fabric.io/public' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
       }

  apply plugin: 'com.android.application'
        apply plugin: 'io.fabric'

     repositories {
maven { url 'https://maven.fabric.io/public' }
      }

//和最后一个 应用插件:'com.google.gms.google-services'