升级到Flutter v3后,Flutter构建失败



我已经将我的应用程序从v2.2.10更新到Flutter 3,它显示以下错误。

FAILURE: Build failed with an exception.
[        ] * Where:
[        ] Script '/Users/user/fvm/versions/3.0.0/packages/flutter_tools/gradle/flutter.gradle' line: 1156
[        ] * What went wrong:
[        ] Execution failed for task ':app:compileFlutterBuildDevDebug'.
[        ] > Process 'command '/Users/user/fvm/versions/3.0.0/bin/flutter'' finished with non-zero exit value 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 2m 56s

事情我已经尝试解决这个问题

  • 升级了依赖项
  • 运行扑动清理
  • 删除构建文件夹
  • 无效并清除Android Studio的缓存
  • 升级Gradle版本
  • 运行扑动医生:没有问题

基本上我已经做了我能想到的所有可能的解决方案。有人遇到过这个问题吗?

这是我构建的内容。gradle文件

buildscript {
ext.kotlin_version = '1.6.21'
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

和我的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"
android {
compileSdkVersion 32
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
applicationId ""
minSdkVersion 23
targetSdkVersion 32
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
signingConfig null
}
debug {
signingConfig null
}
}
flavorDimensions "default"
productFlavors {
//flavor details
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.microsoft.identity.client:msal:1.6.0'
implementation platform('com.google.firebase:firebase-bom:29.0.0')
implementation 'com.google.firebase:firebase-analytics'
}
apply plugin: 'com.google.gms.google-services'

您是否尝试命令dart fix --apply?请给你看gradle文件内容

尝试如下:

flutter channel stable

flutter upgrade

相关内容

  • 没有找到相关文章

最新更新