Home > front end >  Flutter build failed after upgrading to Flutter v3
Flutter build failed after upgrading to Flutter v3

Time:06-08

I've updated my app from v2.2.10 to Flutter 3 and it shows the following error.

     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

Things I've tried to resolve the issue

  • upgraded the dependencies
  • run flutter clean
  • deleted the build folder
  • invalidated and cleared the caches of Android Studio
  • upgraded Gradle version
  • run flutter doctor: No issues

So basically I've done all the possible solutions that could come to my mind. Is there anyone who faced this issue?

Here is the content of my build.gradle file

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
}

And the content of my 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'

CodePudding user response:

Did you try command dart fix --apply? And please show you gradle file content

CodePudding user response:

try

flutter channel stable

flutter upgrade

  • Related