因此,当我尝试将Firebase添加到我的项目中时,我开始遇到这些错误,并且找不到任何已回答的问题。
请帮忙,因为这个Build Failing with an exception when adding firebase_auth or cloud_firestore in the pubspec.yaml file (firebase_core is working):对我不起作用。
这些是我在pubspec.yaml中的依赖项
'''dependencies:
flutter:
sdk: flutter
firebase_core: ^0.5.0
firebase_auth: ^0.18.0+1
cloud_firestore: ^0.14.0+2
firebase_analytics: ^6.0.0
cupertino_icons: ^1.0.0
animated_text_kit: ^2.2.0
google_fonts: 1.0.0'''
这些是app / build.gradle中的依赖项dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.firebase:firebase-analytics-ktx:17.5.0'
implementation 'com.google.firebase:firebase-auth-ktx:19.4.0'
implementation 'com.google.firebase:firebase-firestore-ktx:21.6.0'
}这是错误消息
FAILURE: Build failed with an exception.
* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 362
* What went wrong:
A problem occurred configuring project ':cloud_firestore_web'.
> Could not find method implementation() for arguments [project ':firebase_core'] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
* 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 2s
Finished with error: Gradle task assembleDebug failed with exit code 1
最佳答案
运行flutter upgrade
在您的build.gradle中,删除所有其他内容,如果您的android项目使用的是kotlin,则删除所有其他内容
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
如果不使用kotlin,则仅将以下内容作为依赖项dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
更新在distributionURL
中找到的android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https://services.gradle.org/distributions/gradle--all.zip
之后运行flutter clean
,您会很好
关于firebase - #flutter:配置 ':cloud_firestore_web'时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64035515/