2017-03-05 68 views
0

尝试将Fabric集成到我的Android应用程序的Gradle文件时出现以下错误。'java'插件已应用,但与Android插件不兼容

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

我的摇篮文件如下所示:

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:[email protected]') { 
     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 
} 

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

回答

4

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

删除行与apply plugin: 'java'

0
  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服务'