skip to Main Content

After Upgrading flutter to 3.3.09 and then to .10 The Release Build Only Stopped Working With Problems In Local Notifacations Package, After Many Many Many Edits In Gradle And Kotlin I Stopeed The Error From The Package And A New Error Pops-up
I’ve Tried Every Possible Gradle.Wrapper , Gradle , Kotlin Combination And Allways there is a Compatability Problem, Checked Here And Here And Here To Try To Get A Possible Working Combination With No Luck, And No Fix Found On Stack overflow Helped.

android/gradle

buildscript {
    ext.kotlin_version = '1.5.32'
    repositories {
        google()
        jcenter()
        google() 
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        google()
    }
}

rootProject.buildDir = '../build'
subprojects {
    project.buildDir = "${rootProject.buildDir}/${project.name}"
    project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
    delete rootProject.buildDir
}


app/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"

apply plugin: 'com.google.gms.google-services' //this line

android {
    compileSdkVersion 33

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.laamarRose.laamar_distribution"
        minSdkVersion 21
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }

    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     

            minifyEnabled true
            

            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 

        }
    }
}

flutter {
    source '../..'
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:29.0.3')
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics'
}

gradle-wrapper.properties

#Fri Jul 09 02:12:26 EEST 2021
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip

The Error

* What went wrong:
Execution failed for task ':app:compileReleaseKotlin'.
> Compilation error. See log for more details

* 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 15m 52s
Running Gradle task 'assembleRelease'...                          955.0s

┌─ Flutter Fix ───────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin.                              │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then update │
│ D:LaamarRoseProjectsTrust-Fundtrustfundappandroidbuild.gradle:                                │
│ ext.kotlin_version = '<latest-version>'                                                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────┘

I Would Like To Get The Release Build Working Again Without Deleting Anymore Packages
Tried Multiple Stackoverflow Solutions And Google And Other Scources No Luck

Edit #1
When Setting The ext.kotlin_version = ‘1.6.10’ Got This

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> Could not delete old buildappreportslint-results-release-fatal.html

Trying A Secound Time Showed This Error `

Could not resolve all artifacts for configuration ':flutter_local_notifications:debugUnitTestRuntimeClasspath'.

2

Answers


  1. Please try to change your Kotlin Version hope its help to you. and rebuild again flutter build apk --release command, I just test on my machine

    form

    ext.kotlin_version = '1.5.32'
    

    to

    ext.kotlin_version = '1.6.10'
    

    after succeful build result

    Running Gradle task 'assembleRelease'...                          122.9s
    √  Built buildappoutputsflutter-apkapp-release.apk (42.6MB).
    

    enter image description here

    Login or Signup to reply.
  2. Try doing flutter build apk only. It generates app-release.apk also.

    Location: build/app/outputs/flutter-apk/app-release.apk

    I’m also using flutter v3.3.10. Works for me.

    Edit:

    I use ext.kotlin_version 1.7.20 as mentioned below. Maybe you need to update your build.gradle to a newer version. Also replace jcenter() with mavenCentral() as JCenter Maven repository is no longer receiving updates.

    buildscript {
        ext.kotlin_version = '1.7.20'
        repositories {
            google()
            mavenCentral()
        }
    
        dependencies {
            classpath 'com.android.tools.build:gradle:7.2.2'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.3.14' // this is for firebase
        }
    }
    

    Also do flutter clean and invalidate and clear caches of your IDE, before building release apk.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search