【问题标题】:Error:Execution failed for task ':app:transformClassesWithMultidexlistForDebug'. while adding firebase authentication错误:任务“:app:transformClassesWithMultidexlistForDebug”执行失败。在添加 firebase 身份验证时
【发布时间】:2018-03-18 10:44:52
【问题描述】:

整天都被这个错误困扰。

请不要将此问题标记为重复。我已经回答了许多类似的问题,但没有一个答案对我有用。

完全错误:

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]))

我已经尝试过的事情:

  1. 清理并重建
  2. 使缓存无效并重新启动
  3. 在我的项目文件夹中删除了 .gradle 并重新同步了项目。
  4. 删除了整个 .gradle 的 android studio(在用户/用户名/.gradle 中)几乎 2.5Gb 的数据并再次尝试同步。
  5. 添加:

    android {

    defaultConfig {

    multiDexEnabled true

    }}

到 gradle 文件:

我的完整 gradle 文件:

应用:

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'

顶级等级:

// 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。

【问题讨论】:

  • 你试过加implementation 'com.android.support.multidex:1.0.2'吗?
  • @AlejandroBertinelli 感谢您的回答。接受的答案解决了我的问题。

标签: android firebase firebase-authentication


【解决方案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'

FirebaseUi-Android releases

【讨论】:

  • 所以 Firebase UI 不支持最新的支持库!!!在这个错误上花了很多时间:-(并且还必须删除我在 .gradle 文件夹中的所有库。(必须重新下载它们)。非常感谢您的回答。:-)
  • @Abhi 等等...用户会责备您,因为 Auth UI 不会让他们从登录屏幕返回...
  • @AlejandroBertinelli 对不起,我听不懂你说的。
  • @JagarYousef 你什么都不懂?
【解决方案2】:

正如@Jagar 在他的回答中解释的那样,FirebaseUI 3.2.2 在支持库 27.0.2 上有 transitive dependencies。如果您想使用不同版本的支持库(例如 27.1.0)进行构建,则必须按照 instructions described in the documentation 在依赖项中添加适当的库。在您的情况下,对于 FirebaseUI 身份验证,这些是:

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'

【讨论】:

    猜你喜欢
    • 2016-01-23
    • 2018-06-09
    • 1970-01-01
    • 2018-08-01
    • 2018-04-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多