我按照在firestore中注册我的移动应用程序的步骤,但当我尝试运行代码时,我得到以下错误。我在注册我的应用程序时从firestore下载了google services.json,并将其添加到我的项目的android/app级别。我还在我的android/app/build gradle文件中添加了“com.google.firebase:firebase-analytics-ktx”
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
> Could not find com.google.firebase:firebase-analytics-ktx:.
Required by:
project :app
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
我的项目级别构建如下
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
我的应用程序级别构建gradle如下
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.ashniz.firestore_time_compare"
minSdkVersion 21
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.google.firebase:firebase-analytics-ktx'
}
apply plugin: 'com.google.gms.google-services'
有人知道如何解决这个问题吗?谢谢
7条答案
按热度按时间vddsk6oq1#
尝试替换此dep
与
wi3ka0sx2#
我只能像这样使用
build.gradle.kts
获得firebase BOM:mqkwyuun3#
与其依赖于可能不兼容的不同Firebase库的特定版本,您可能希望开始使用 * 物料清单 *,例如:
Firebase Android BoM(物料清单)允许您通过仅指定一个版本(BoM版本)来管理所有Firebase库版本。
当您在应用中使用Firebase BoM时,BoM会自动拉入Map到BoM版本的单个库版本。所有单个库版本都将兼容。当您在应用中更新BoM版本时,您在应用中使用的所有Firebase库都将更新到Map到该BoM版本的版本。
如欲了解更多信息,请访问https://firebase.google.com/docs/android/learn-more#bom
rqcrx0a64#
我遇到了类似的问题,在我的例子中,我使用的是BOM,但是我声明了BOM依赖关系,如下所示
代替
ztigrdn85#
所有你需要更新flutter sdk运行该命令在终端:
完成更新后,构建新项目并将其链接到firebase,但要确保在'PROJECT_PATH/android/app/build. gradle'中,minSdkVersion为19或更高版本。
iqjalb3h6#
我遇到了同样的问题,对我有效的BOM实现是这样的-
如文档中所述,在使用BOM实施时,我们不需要指定分析的版本
下面的代码应该与java一起使用-
With java
和Kotlin-
with kotlin
以下内容不能与BOM一起使用
bom take cares of version
有关https://firebase.google.com/docs/android/learn-more?authuser=0&hl=en#bom物料清单(BoM)的更多信息,请访问- www.example.com
jc3wubiy7#
请尝试将以下内容添加到您的biuld.gradle文件: