无法在 android studio 中设置 firebase
Posted
技术标签:
【中文标题】无法在 android studio 中设置 firebase【英文标题】:Unable to setup firebase in android studio 【发布时间】:2021-09-17 16:14:39 【问题描述】:所以我正在尝试设置 firebase 并制作一个应用程序,一旦您打开该应用程序,该应用程序就允许基本登录功能,但我的构建失败并显示以下消息:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.firebaseui:firebase-ui-firestore:6.4.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/firebaseui/firebase-ui-firestore/6.4.0/firebase-ui-firestore-6.4.0.pom
- https://repo.maven.apache.org/maven2/com/firebaseui/firebase-ui-firestore/6.4.0/firebase-ui-firestore-6.4.0.pom
Required by:
project :app
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
我的应用级别gradle如下:
plugins
id 'com.android.application'
id 'kotlin-android'
id 'com.google.gms.google-services'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
android
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig
applicationId "com.example.socialapp"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
compileOptions
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
kotlinOptions
jvmTarget = '1.8'
dependencies
implementation "androidx.appcompat:appcompat:$rootProject.appCompatVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"
// UI
implementation "androidx.constraintlayout:constraintlayout:$rootProject.constraintLayoutVersion"
implementation "com.google.android.material:material:$rootProject.materialVersion"
/* coroutines support for firebase operations */
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.1.1'
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:26.1.0')
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.firebaseui:firebase-ui-firestore:6.4.0'
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
// Testing
testImplementation "junit:junit:$rootProject.junitVersion"
androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"
androidTestImplementation ("androidx.test.espresso:espresso-core:$rootProject.espressoVersion",
exclude group: 'com.android.support', module: 'support-annotations'
)
androidTestImplementation "androidx.test.ext:junit:$rootProject.androidxJunitVersion"
我的项目级gradle如下:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
ext.kotlin_version = "1.5.20"
repositories
google()
mavenCentral()
dependencies
classpath "com.android.tools.build:gradle:4.2.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
allprojects
repositories
google()
mavenCentral()
//jcenter() // Warning: this repository is going to shut down soon
task clean(type: Delete)
delete rootProject.buildDir
ext
appCompatVersion = '1.2.0'
constraintLayoutVersion = '2.0.2'
coreTestingVersion = '2.1.0'
coroutines = '1.3.9'
lifecycleVersion = '2.2.0'
materialVersion = '1.2.1'
// testing
junitVersion = '4.13.1'
espressoVersion = '3.1.0'
androidxJunitVersion = '1.1.2'
我无法找到此错误消息的确切解决方案,但我遇到了类似错误消息的解决方案,但它们似乎不起作用,我们将不胜感激!
【问题讨论】:
【参考方案1】:根据文档,您应该从 6.4.0 升级到 7.x.x,因此您的 gradle 应该如下所示:
// FirebaseUI for Cloud Firestore
implementation 'com.firebaseui:firebase-ui-firestore:7.2.0'
另外,您是否应用了 Google 服务应用插件:“com.google.gms.google-services”并确保您已更新
【讨论】:
升级 7.x.x 后出现以下错误:无法将请求的类放入单个 dex 文件中(# 方法:117225 > 65536)【参考方案2】:我通过更新解决了这个问题
com.google.gms:google-services:4.3.8
到版本 4.3.10
和
com.firebaseui:firebase-ui-firestore:6.4.0
到 8.0.0
【讨论】:
以上是关于无法在 android studio 中设置 firebase的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Visual Studio 2008 或 Visual Studio 2010 中设置 JavaScript 断点
在 Visual Studio 2015 中设置 TSLint
如何在 Visual Studio 2010 中设置 Qt 路径?