android - 我正在使用 Android 制作聊天应用程序。我无法连接到 Firebase
问题描述
IT 表示“无法解析 Android 应用程序模块的 Gradle 配置。解决 gradle 构建问题和/或重新同步。
下面是我的 build.gradle 模块。
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.mchat"
minSdkVersion 27
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
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.intuit.sdp:sdp-android:1.0.6'
}
解决方案
确保 Android Studio 已更新并且您使用的是 Gradle 4.1 或更高版本。另外,我在您的依赖项中看不到谷歌服务:
com.google.gms.google-services
我建议仔细检查文档中的步骤,以确保您已正确实施 firebase。 https://firebase.google.com/docs/android/setup#add-config-file
在某些情况下,您的缓存构建可能已损坏,并且可能需要删除.gradle/caches
目录。它包含 Gradle 构建缓存,如果您有关于构建缓存的错误,您可以安全地删除它以进行干净的构建。
此外--no-build-cache选项将在没有构建缓存的情况下运行 Gradle。
推荐阅读
- typescript - 如何在打字稿中扩展全局属性?
- c++ - Qt SQlite 无法创建表
- android - 从另一个活动中读取位图 -> 空图像
- python - 日期时间值数组
- angular - Angular 9 中与动画相关的更改检测行为
- python - 在 TensorFlow 2 中使用特定类型的输入运行 SavedModel
- ruby-on-rails - Rails 6 AssociationTypeMismatch 与 fields_for
- snowflake-cloud-data-platform - 如何在雪花中进行自然排序?
- sql - 如何编写 SQL 查询(获取所有类别并在每个类别上获取 10 个产品)
- powerbi - 如何显示一个列表的哪些值在另一个列表中?