gpt4 book ai didi

firebase - 将依赖项添加到VScode中的gradle后无法同步

转载 作者:行者123 更新时间:2023-12-03 04:49:28 27 4
gpt4 key购买 nike

我尝试配置flutter项目以使用Firebase。我将所有依赖项添加了,并且在将Firebase中提到的行添加到Gradle构建中之后无法同步。
如何同步 vscode

为Firebase添加了依赖度:

在项目中-> android-> app-> build.gradle:

apply plugin: 'com.google.gms.google-services'

在项目中-> gradle-> build.gradle:
 dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
**classpath 'com.google.gms:google-services:4.3.3'**
}

IN项目-> pubspec.yaml
firebase_auth: ^0.14.0+5

还跑了 flutter pub get
错误日志:
* Error running Gradle:
ProcessException: Process "C:\Users\LENOVO\Documents\flutter_apps\time_tracker_flutter_course\android\gradlew.bat" exited abnormally:
Starting a Gradle Daemon (subsequent builds will be faster)


FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\LENOVO\Documents\flutter_apps\time_tracker_flutter_course\android\app\build.gradle' line: 24

* What went wrong:
A problem occurred evaluating project ':app'.
> ASCII

* 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 2m 23s
Command: C:\Users\LENOVO\Documents\flutter_apps\time_tracker_flutter_course\android\gradlew.bat app:properties

Please review your Gradle project setup in the android/ folder.
Exited (sigterm)

最佳答案

使用Firebase时,您需要下载google-services.json文件并将其添加到您的项目中:

Where do I place Googleservices.json in Flutter app in order to solve 'google-services.json is missing'

然后在android/build.gradle中,您需要添加google()maven存储库:

buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.3'
}
}

allprojects {
...
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
...
}
}

android\app\build.gradle内,您需要添加 google-service插件:
apply plugin: 'com.google.gms.google-services'

检查一下:

https://firebase.google.com/docs/flutter/setup?platform=android

关于firebase - 将依赖项添加到VScode中的gradle后无法同步,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61651329/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com