尝试将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文件中重新排序?
答案 0 :(得分:4)
您不能在同一模块中同时应用com.android.application
和java
插件。
删除行apply plugin: 'java'
答案 1 :(得分: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' }
}
//和最后一个 申请插件:&#39; com.google.gms.google-services&#39;