Ash*_*zam 10 gradle firebase flutter firebase-analytics
我按照在 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
Run Code Online (Sandbox Code Playgroud)
我的项目级别构建 gradle 如下
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
}
Run Code Online (Sandbox Code Playgroud)
我的应用程序级别构建 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'
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?谢谢
Mor*_*ard 21
我只能让 firebase BoM 像build.gradle.kts这样工作:
implementation(platform("com.google.firebase:firebase-bom:28.4.1"))
implementation("com.google.firebase:firebase-analytics-ktx")
implementation("com.google.firebase:firebase-crashlytics-ktx")
Run Code Online (Sandbox Code Playgroud)
use*_*158 16
我有一个类似的问题,在我的例子中我使用的是 BoM,但我已经声明了 BoM 依赖项,例如
implementation 'com.google.firebase:firebase-bom:28.0.1' // without platform
Run Code Online (Sandbox Code Playgroud)
代替
implementation platform('com.google.firebase:firebase-bom:28.0.1')
Run Code Online (Sandbox Code Playgroud)
GJJ*_*GJJ 11
尝试更换这个 dep
implementation 'com.google.firebase:firebase-analytics-ktx'
Run Code Online (Sandbox Code Playgroud)
和
implementation 'com.google.firebase:firebase-analytics:17.5.0'
Run Code Online (Sandbox Code Playgroud)
您可能希望开始使用材料清单,而不是依赖于可能不兼容的不同 Firebase 库的特定版本,例如:
dependencies {
// Import the BoM for the Firebase platform
implementation platform('com.google.firebase:firebase-bom:26.5.0')
// Declare the dependencies for the desired Firebase products without specifying versions
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
}
Run Code Online (Sandbox Code Playgroud)
Firebase Android BoM(物料清单)使您能够通过仅指定一个版本(BoM 的版本)来管理所有 Firebase 库版本。
当您在应用中使用 Firebase BoM 时,BoM 会自动提取映射到 BoM 版本的各个库版本。所有单独的库版本都将兼容。当您更新应用中的 BoM 版本时,您在应用中使用的所有 Firebase 库都将更新为映射到该 BoM 版本的版本。
在https://firebase.google.com/docs/android/learn-more#bom了解更多信息
| 归档时间: |
|
| 查看次数: |
7037 次 |
| 最近记录: |