整天都在遭受这个错误。
请不要将此问题标记为重复。我已经遇到了许多类似的问题,但没有一个答案适用于我。
完整错误:
Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> java.io.IOException: Can't write [E:\Educational\Career\Android\Projects
\FirebaseTutorial\app\build\intermediates\multi-dex\debug\componentClasses.jar]
(Can't read [C:\Users\Abhi\.gradle\caches\transforms-1\files-1.1\support-core-ui-
27.1.0.aar\167562b027fa4c1af2f69bce0de3dd43\jars\classes.jar(;;;;;;**.class)]
(Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout
$Behavior.class]))
我已经尝试过的事情:
已添加:
android {
defaultConfig {
multiDexEnabled true
}}
到gradle文件:
我的完整gradle文件:
app:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.appz.abhi.firebasetutorial"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
顶级gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
添加firebase身份验证后发生此错误。
P.S:删除firebase auth依赖项并重建项目不会显示任何错误。即删除
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
删除了错误,但我想在我的项目中使用firebase Auth。
答案 0 :(得分:1)
firebase-ui-auth:3.2.2
支持的支持库是27.0.2而不是27.1.0
所以改变:
implementation 'com.android.support:appcompat-v7:27.1.0'
到
implementation 'com.android.support:appcompat-v7:27.0.2'
答案 1 :(得分:0)
正如@Jagar在他的回答中解释的那样,FirebaseUI 3.2.2在支持库27.0.2上有transitive dependencies。如果要使用不同版本的支持库(例如27.1.0)进行构建,则必须遵循instructions described in the documentation在依赖项中添加相应的库。在您的情况下,对于FirebaseUI Auth,它们是:
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:customtabs:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'