错误:程序类型已经存在:android.arch.lifecycle.LiveData [英] Error:Program type already present: android.arch.lifecycle.LiveData

查看:55
本文介绍了错误:程序类型已经存在:android.arch.lifecycle.LiveData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在 Android Studio 中按下运行按钮时,我的应用程序编译但显示此错误(已编辑):

When I press the run button in Android Studio, my app compiles but shows this error (redacted):

Error:Program type already present: android.arch.lifecycle.LiveData

(完整日志)

我尝试删除 .gradle 文件夹,然后转到 Build >Clean ProjectBuild >重建项目.但是,它不起作用.我还尝试删除源代码,然后从 git 再次克隆并将文件夹导入 Android Studio.但是,它仍然会产生该错误.

I've tried deleting the .gradle folder, then going to Build > Clean Project and Build > Rebuild Project. However, it doesn't work. I've also tried deleting the source code, then cloning again from git and importing the folder to Android Studio. However, it still produces that error.

这是我的应用程序的app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion '27.0.3'
    defaultConfig {
        applicationId "com.edricchan.studybuddy"
        minSdkVersion 24
        targetSdkVersion 27
        versionCode 8
        versionName "1.0.0-rc.503"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        resConfigs "en"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dataBinding {
        enabled = true
    }
}

dependencies {
    implementation 'com.android.support:support-v4:27.1.0'
    implementation 'com.android.support:support-annotations:27.1.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    testImplementation 'junit:junit:4.12'
    // Firebase stuff
    implementation 'com.google.firebase:firebase-storage:11.8.0'
    implementation 'com.google.firebase:firebase-firestore:11.8.0'
    implementation 'com.google.firebase:firebase-auth:11.8.0'
    implementation 'com.google.firebase:firebase-messaging:11.8.0'
    implementation 'com.google.android.gms:play-services-auth:11.8.0'
    implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
    implementation 'com.firebaseui:firebase-ui-firestore:3.1.0'
    implementation 'com.firebaseui:firebase-ui-storage:3.1.0'
    // Provide a way to update the app
    implementation 'com.github.javiersantos:AppUpdater:2.6.4'
    // Chrome Custom Tabs
    implementation 'com.android.support:customtabs:27.1.0'
    // The app's intro screen
    implementation 'com.heinrichreimersoftware:material-intro:1.6.2'
    // Use for new Material Text field boxes recently introduced
    implementation 'com.github.HITGIF:TextFieldBoxes:1.3.7'
    // Report an issue to Github without having to open a new tab and so on...
    implementation 'com.heinrichreimersoftware:android-issue-reporter:1.3.1'
}
apply plugin: 'com.google.gms.google-services'

推荐答案

显然,这是预期的行为:

Apparently, this is intended behavior:

com.firebaseui:firebase-ui-firestore:3.1.0 依赖于 android.arch.lifecycle:extensions:1.0.0-beta1.切换到 3.2.2 版通过使用支持库 27.1.0 所基于的 Lifecycle 1.1 库修复了该问题.- 问题跟踪器

com.firebaseui:firebase-ui-firestore:3.1.0 depends on android.arch.lifecycle:extensions:1.0.0-beta1. Switching to version 3.2.2 fixes the issue by using the Lifecycle 1.1 libraries that Support Library 27.1.0 are built upon. - Issue Tracker

对我来说,删除 firebase-ui 依赖项解决了这个问题,因为我一开始甚至没有使用这个库.

For me, removing the firebase-ui dependencies solved the issue since I wasn't even using the library in the first place.

这篇关于错误:程序类型已经存在:android.arch.lifecycle.LiveData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆