Flutter 上的 Firebase 错误:无法解析配置“:firebase_core:debugCompileClasspath”的所有任务依赖项
Posted
技术标签:
【中文标题】Flutter 上的 Firebase 错误:无法解析配置“:firebase_core:debugCompileClasspath”的所有任务依赖项【英文标题】:Firebase Erorr on Flutter: Could not resolve all task dependencies for configuration ':firebase_core:debugCompileClasspath' 【发布时间】:2021-05-25 09:23:17 【问题描述】:嘿,我是 firebase flutter 的新手,我想用 firebase 的身份验证来制作登录页面。在我为我的项目制作登录页面和所有设置 fromo 文档后,我得到了这个错误。
我尝试pub clear cache
并没有解决问题。
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':firebase_core:compileDebugAidl'.
> Could not resolve all task dependencies for configuration ':firebase_core:debugCompileClasspath'.
> Could not find com.google.firebase:firebase-common:.
Required by:
project :firebase_core
* 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 16s
Exception: Gradle task assembleDebug failed with exit code 1
* 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 16s
Exception: Gradle task assembleDebug failed with exit code 1
这是我的 pubspec.yaml 和最新版本的 firebase
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for ios style icons.
cupertino_icons: ^1.0.0
google_fonts: ^1.1.0
flutter_svg: ^0.18.0
animate_icons: ^1.0.0
motion_tab_bar: ^0.1.5
simple_animations: ^1.3.3
#firebase
firebase_core: ^0.7.0
firebase_analytics: ^7.0.1
firebase_auth: ^0.20.1
cloud_firestore: ^0.16.0+1
provider: ^4.3.3
dev_dependencies:
flutter_test:
sdk: flutter
app/build.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"
apply plugin: 'com.google.gms.google-services' // Google Services plugin
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 "id.skyward.plantgo"
minSdkVersion 23
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
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
minifyEnabled true
debug
minifyEnabled true
flutter
source '../..'
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.5.0')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
rootProject.ext
set('FlutterFire', [
FirebaseSDKVersion: '25.12.0'
])
build.gradle
buildscript
ext.kotlin_version = '1.3.50'
repositories
jcenter()
google()
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.5' // Google Services plugin
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0'
allprojects
repositories
jcenter()
google()
rootProject.buildDir = '../build'
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
subprojects
project.evaluationDependsOn(':app')
task clean(type: Delete)
delete rootProject.buildDir
【问题讨论】:
【参考方案1】:我已经更新了你的app/build.gradle
文件,请试试这个。
我刚刚添加了一行implementation 'com.google.firebase:firebase-core:17.0.1'
。
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"
apply plugin: 'com.google.gms.google-services' // Google Services plugin
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 "id.skyward.plantgo"
minSdkVersion 23
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
minifyEnabled true
debug
minifyEnabled true
flutter
source '../..'
dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:26.5.0')
// Add the dependency for the Firebase SDK for Google Analytics
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
// Add the dependencies for any other desired Firebase products
// https://firebase.google.com/docs/android/setup#available-libraries
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-core:17.0.1'
rootProject.ext
set('FlutterFire', [
FirebaseSDKVersion: '25.12.0'
])
【讨论】:
hei thx for answer,我已经尝试过您的解决方案。但还是一样的错误 @skyward17 请立即尝试新代码,因为我只有一些添加一行 我也尝试添加该行,可悲的是我仍然有同样的错误【参考方案2】:UPDATE
我找到了答案。在app/build.gradle
files,这一行FirebaseSDKVersion: '25.12.0'
是问题所在。
它应该与implementation platform('com.google.firebase:firebase-bom:26.5.0')
相同的版本
所以我改为FirebaseSDKVersion: '25.12.0'
然后firebase核心它的工作。
【讨论】:
以上是关于Flutter 上的 Firebase 错误:无法解析配置“:firebase_core:debugCompileClasspath”的所有任务依赖项的主要内容,如果未能解决你的问题,请参考以下文章
为最终用户处理 Flutter 上的 Firebase 身份验证错误
Flutter:无法从 firebase 读取数据。方法 '[]' 在 null 错误上被调用
Flutter XCode-build 错误无法构建模块'firebase_core'
Flutter 项目中的 Application.kt 给出错误 - 无法访问“com.google.firebase.messaging.zzf”