android - 出现错误 : "Failed to resolve: localbroadcastmanager" in Connecting Android project to Firebase

标签 android firebase android-studio gradle

我正在尝试将 Firebase 连接到 Android,但同步项目时出现错误。我有最新版本的 google 存储库,并且已将所需的依赖项添加到项目级别 build.gradle 和应用程序级别 build.gradle。

下面是我的应用程序级 Gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
    applicationId "com.example.ecommerce"
    minSdkVersion 19
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.+'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:17.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 
  }
  apply plugin: 'com.google.gms.google-services'

还有我的项目级 gradle:

buildscript {
repositories {
    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
    classpath 'com.google.gms:google-services:4.2.0' 
     }
  }

allprojects {
  repositories {
    google()
    jcenter()

    maven {
        url "https://maven.google.com"
    }
 }
 } 
 task clean(type: Delete) {
   delete rootProject.buildDir
   }

最佳答案

我已迁移到 androidx。我还在我的应用程序级 Gradle 中添加了以下行,它起作用了:

   implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'

关于android - 出现错误 : "Failed to resolve: localbroadcastmanager" in Connecting Android project to Firebase,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57567485/

相关文章:

Android Studio "Error Installing APK"到小米手机

android - 插件指令在 gradle 文件中的什么位置?

android - 带有textview参数的AsyncTask

android - 在不显示选择器的情况下启动 native 相机

android - 检查 Android 应用大小

javascript - 如何仅存储特定用户的数据

android - Lawnchair + Android + PhoneGap 工作,但不持久

node.js - Firebase 身份验证(不是函数,也不是构造函数)

firebase - 什么用例有 FirebaseUser 的 reload() 功能?

android - 如何在 recyclerview 中为每个 cardview 实现单选警报对话框?