Flutter Firebase 插件问题:不兼容问题
Posted
技术标签:
【中文标题】Flutter Firebase 插件问题:不兼容问题【英文标题】:Flutter Firebase Plugin Issues: Incompatibility issues 【发布时间】:2020-04-01 03:06:33 【问题描述】:在我将 firebase 插件添加到我的颤振项目后,出现以下错误: ProcessException:进程“C:\projects\ecommerce\android\gradlew.bat”异常退出: 启动 Gradle 守护进程(后续构建会更快)
FAILURE:构建失败并出现异常。 * 在哪里: 构建文件 'C:\projects\ecommerce\android\app\build.gradle' 行:24 * 什么地方出了错: 评估项目 ':app' 时出现问题。
无法应用插件 [id 'com.android.application'] 支持的最低 Gradle 版本为 5.4.1。当前版本是 4.10.2。如果使用 gradle 包装器,请尝试编辑 C:\projects\ecommerce\android\gradle\wrapper\gradle-wrapper.properties 中的 distributionUrl 到 gradle-5.4.1-all.zip。
这是我的 android\app\build.gradle。
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"
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 "com.example.ecommerce"
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
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
apply plugin: 'com.google.gms.google-services'
这是我的 android\build.gradle:
buildscript
ext.kotlin_version = '1.2.71'
repositories
google()
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
allprojects
repositories
google()
jcenter()
rootProject.buildDir = '../build'
subprojects
project.buildDir = "$rootProject.buildDir/$project.name"
// ====SUBPROJECT DEPENDENCIES START HERE
subprojects
project.evaluationDependsOn(':app')
project.configurations.all
resolutionStrategy.eachDependency details ->
if (details.requested.group == 'androidx.core'
&& !details.requested.name.contains('androidx') )
details.useVersion "1.0.1"
//ENDS HERE
task clean(type: Delete)
delete rootProject.buildDir
C:\Program Files\Android\Android Studio\gradle中的gradle版本: 是5.1.1。 我的 android\build.gradle 中的 gradle 版本, 依赖:
dependencies
classpath 'com.android.tools.build:gradle:3.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.2'
```
I dont know if there's any conflict between
```classpath 'com.google.gms:google-services:4.3.2' ```
with:
```classpath 'com.android.tools.build:gradle:3.5.2'```
Please help
【问题讨论】:
【参考方案1】:这些是我在最近一次演示中使用的链接。它们包含截至 3 周前所有内容的必要版本。试一试。
Firebase 身份验证:
https://github.com/flutter/flutter/issues/41492#issuecomment-536112970 https://github.com/flutter/flutter/issues/27254#issuecomment-477474444
云防火墙:
https://developer.android.com/studio/build/multidex#mdex-gradle
【讨论】:
【参考方案2】:所以,在整个互联网上梳理了两天后,我终于通过更改
classpath 'com.google.gms:google-services:4.3.2'
至,classpath 'com.google.gms:google-services:4.2.0'
另外,在 android/build.gradle 文件中升级我的 gradle 依赖项: 来自:
classpath 'com.android.tools.build:gradle:3.2.1'
收件人:
classpath 'com.android.tools.build:gradle:3.3.1'
会帮忙
如果遇到同样的问题,您可以参考这篇文章: https://github.com/flutter/flutter/issues/38163#issuecomment-520429066
【讨论】:
以上是关于Flutter Firebase 插件问题:不兼容问题的主要内容,如果未能解决你的问题,请参考以下文章
Flutter 设备预览和 Firebase 身份验证不兼容
Flutter:CocoaPods 找不到 pod“Firebase/Messaging”的兼容版本