我最近更新了Build.Gradle文件,但我的项目没有成功构建。在研究了几个可能的问题后,我遇到了[这篇文章] [1],表明它可能与我的Firebase依赖项发生冲突。它也可能与multidex有关,但基于错误的模糊程度,我甚至没有起点:
错误:
Program type already present: android.arch.core.util.Function
的build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
vectorDrawables.useSupportLibrary = true
applicationId "xxxxxxxx"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
// Support library
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:appcompat-v7:27.1.1"
// Firebase
implementation "com.google.firebase:firebase-storage:16.0.1"
implementation "com.google.firebase:firebase-core:16.0.0"
implementation "com.google.firebase:firebase-auth:16.0.1"
implementation "com.google.android.gms:play-services-auth:15.0.1"
// implementation "com.google.firebase:firebase-database:$playServicesVersion"
implementation "com.google.firebase:firebase-appindexing:15.0.1"
implementation "com.google.firebase:firebase-firestore:17.0.1"
implementation 'com.firebaseui:firebase-ui-firestore:4.0.0'
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
// Third party
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.facebook.android:facebook-android-sdk:4.+'
implementation 'jp.wasabeef:recyclerview-animators:2.2.3'
implementation 'com.github.clans:fab:1.6.2'
implementation 'de.hdodenhof:circleimageview:2.0.0'
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.squareup.okhttp3:okhttp:3.1.2'
implementation 'com.github.PhilJay:MPAndroidChart:v2.2.2'
implementation 'com.google.code.gson:gson:2.6.2'
implementation 'com.squareup.retrofit2:retrofit:2.1.0'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.android.support:multidex:1.0.3'
}
的build.gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
maven { url 'https://jitpack.io' }
maven { url "https://maven.google.com" }
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
supportLibVersion = "27.1.1"
playServicesVersion = "17.0.1"
}
答案 0 :(得分:3)
添加这些依赖项:
implementation "android.arch.core:runtime:$version"
implementation "android.arch.core:common:$version"
您可以在此处找到更多信息:https://github.com/firebase/FirebaseUI-Android/issues/1357