我收到此错误:
错误:任务执行失败 ':应用程序:transformClassesWithDexForDebug'
com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:com.android.dex.DexException: 多个dex文件定义Lcom / google / android / gms / internal / zzeg;
运行应用程序时!
但我猜问题就在于gradle。我搜索了解决方案,我发现可能有不同版本的播放服务声明。但我没有发现任何错误!
请帮我解决问题。我是Firebase和依赖项的新手。
这是我的构建gradle(app):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是build.gradle(项目)文件:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.eaglewap.cleancity"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
// Displaying images
compile 'com.github.bumptech.glide:glide:3.6.1'
//Firebase
compile 'com.google.firebase:firebase-database:11.2.2'
compile 'com.google.firebase:firebase-storage:11.2.2'
compile 'com.google.firebase:firebase-auth:11.2.2'
compile 'com.google.firebase:firebase-messaging:11.2.2'
compile 'com.google.firebase:firebase-config:11.2.2'
//Firebase UI
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:2.3.0'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
答案 0 :(得分:1)
这是因为当你使用:
// Single target that includes all FirebaseUI libraries above
compile 'com.firebaseui:firebase-ui:2.3.0'
与使用相同:
// FirebaseUI Database only
compile 'com.firebaseui:firebase-ui-database:2.3.0'
// FirebaseUI Auth only
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
// FirebaseUI Storage only
compile 'com.firebaseui:firebase-ui-storage:2.3.0'
位于documentation,它表示需要Firebase / Play服务版本11.0.4。但是你使用11.2.2,所以firebase-ui库将包含它的传递依赖,它使用的是11.0.4。因此发生了冲突。
因此,您可以使用Firebase / Play服务版本11.0.4,也可以添加播放服务验证。
对于Auth,您需要包含播放服务版本:
compile "com.google.firebase:firebase-auth:11.2.2"
compile "com.google.android.gms:play-services-auth:11.2.2"