为啥 Firebase 安装过程给我一个错误?扑
Posted
技术标签:
【中文标题】为啥 Firebase 安装过程给我一个错误?扑【英文标题】:Why does the Firebase installation process give me an error? Flutter为什么 Firebase 安装过程给我一个错误?扑 【发布时间】:2020-10-29 02:55:39 【问题描述】:我试图在我的颤振应用程序中使用 Firebase 来存储一些数据,但是当尝试将 sdk 安装到我的 gradle 中时,gradle 完全搞砸了,现在它不受支持。即使我删除了所有更改,gradle 仍然说它不受支持。请告诉我错误是在哪里产生的。 我的*** gradle.build 文件:
buildscript
repositories
google()
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.google.gms:google-services:4.3.3'
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 plugin: 'com.google.gms.google-services'
android
compileSdkVersion 28
lintOptions
disable 'InvalidPackage'
defaultConfig
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "org.RiverRipple.cibo"
minSdkVersion 16
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.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'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
我的 gradle-wrapper.properties 文件:
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
请告诉我问题是在哪里产生的。
【问题讨论】:
【参考方案1】:更改minSdkVersion
:
minSdkVersion 16
到:
minSdkVersion 21
还在build.gradle
中添加以下内容:
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
Firebase 需要minSdkVersion 21
才能运行
【讨论】:
非常感谢!我被困在这个错误上的时间比我想承认的要长,但现在我可以继续前进了。它在调试控制台中用红色文本给我一个注释,但我不知道它是什么意思。该应用程序运行良好,但我想确保这不会有问题。 注:C:\Users\kkanc\Downloads\flutter_windows_1.17.4-stable\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\ main\java\io\flutter\plugins\firebase\cloudfirestore\CloudFirestorePlugin.java 使用或覆盖已弃用的 API。注意:使用 -Xlint:deprecation 重新编译以获取详细信息。注意:C:\Users\kkanc\Downloads\flutter_windows_1.17.4-stable\flutter\.pub-cache\hosted\pub.dartlang.org\cloud_firestore-0.12.11\android\src\main\java\io\flutter\ plugins\firebase\cloudfirestore\CloudFirestorePlugin.java 使用未经检查或不安全的操作。 更新cloud_firestore,使用最新版本pub.dev/packages/cloud_firestore#-installing-tab-以上是关于为啥 Firebase 安装过程给我一个错误?扑的主要内容,如果未能解决你的问题,请参考以下文章