2017-03-05 73 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服務'

相關問題