android - pub get failed: 因为flutter_app依赖firebase_firestore ^0.12.7+1 不匹配任何版本,版本解析失败
问题描述
pub get failed: Because flutter_app depends on firebase_firestore ^0.12.7+1 which doesn't match any versions, version solving failed.
尝试flutter pub get
在 pubspec.yaml 文件中运行时出现此错误。我目前正在尝试设置 firebase https://firebase.google.com/docs/flutter/setup。
这是我的 pubspec.yaml 文件:
name: flutter_app
description: A new Flutter application.
version: 1.0.0+1
environment:
sdk: ">=2.1.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: ^0.1.2
# Add the dependency for the Firebase Core Flutter SDK
firebase_core: ^0.4.0+1
# Add the dependency for the FlutterFire plugin for Google Analytics
firebase_analytics: ^4.0.2
# Add the dependencies for any other Firebase products you want to use in your app
# For example, to use Firebase Authentication and Cloud Firestore
firebase_auth: ^0.11.1+3
firebase_firestore: ^0.12.7+1
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
构建.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:3.2.1'
}
}
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
}
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 from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 28
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.flutter_app"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
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 {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
apply plugin: 'com.google.gms.google-services'
我注意到第二个 build.gradle 文件包含几个标记的错误,但我不确定这是否意味着什么。
感谢您的帮助!
解决方案
firebase_firestore 包已被弃用,它的最后一个版本是 0.0.3+1...所以它找不到版本 ^0.12.7+1
您将需要改为 cloud_firestore:
https://pub.dev/packages/cloud_firestore
尝试关注 Flutter 团队最新的 Firebase 代码实验室。
https://flutter.dev/docs/development/data-and-backend/firebase
推荐阅读
- flutter - 颤振错误:“不能将‘Null’类型的值分配给‘Product’类型的变量。”
- javascript - 这个简单的 Firefox 扩展可以变成 Greasemonkey 脚本吗?
- c# - 如何从 IntPtr 句柄创建 WPF 光标
- javascript - 为什么我的请求在邮递员而不是axios中工作?
- javascript - JavaScript算法:如何在数组中找到所有局部最大值
- reactjs - 有没有办法从 react-color 库中垂直旋转 SliderPicker?
- c# - Nuget Library .exe 没有出现在主项目中
- php - 简码内的简码或嵌套简码(//注释中的注释)
- javascript - 如何构建我的 TypeScript API 的“索引”,而不会一直显示在 IntelliSense 上?
- r - R Markdown/Flexdashboard