将Android项目连接到Firebase中出现错误:“无法解决:localbroadcastmanager”

时间:2019-08-20 06:02:14

标签: 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
   }

1 个答案:

答案 0 :(得分:2)

我移民到androidx。我还在我的应用程序级别的Gradle中添加了以下代码,它可以正常工作:

   implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'