From 6f2e7e51cb6562bec2bc8ccefca432538be19a1f Mon Sep 17 00:00:00 2001 From: JTorkk Date: Wed, 17 Jun 2026 15:15:24 +0300 Subject: [PATCH 1/2] chore: upgrade Gradle to 8.14 and migrate Android build configuration to the modern Flutter plugin DSL --- example/android/app/build.gradle | 25 +++++----------- example/android/build.gradle | 13 -------- example/android/gradle.properties | 5 ++-- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 30 ++++++++++++++----- 5 files changed, 32 insertions(+), 43 deletions(-) diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index b52183a..337f92e 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,3 +1,8 @@ +plugins { + id "com.android.application" + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { @@ -6,11 +11,6 @@ if (localPropertiesFile.exists()) { } } -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' @@ -21,11 +21,8 @@ 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 { + namespace "com.example.example" compileSdkVersion flutter.compileSdkVersion ndkVersion flutter.ndkVersion @@ -38,15 +35,13 @@ android { jvmTarget = '1.8' } + 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.example.example" - // You can update the following values to match your application needs. - // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. minSdkVersion flutter.minSdkVersion targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() @@ -55,8 +50,6 @@ android { 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 } } @@ -65,7 +58,3 @@ android { flutter { source '../..' } - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" -} diff --git a/example/android/build.gradle b/example/android/build.gradle index 713d7f6..bc157bd 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -1,16 +1,3 @@ -buildscript { - ext.kotlin_version = '1.7.10' - repositories { - google() - mavenCentral() - } - - dependencies { - classpath 'com.android.tools.build:gradle:7.2.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() diff --git a/example/android/gradle.properties b/example/android/gradle.properties index eac5ff9..574d10e 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,7 +1,6 @@ -org.gradle.jvmargs=-Xmx1536M +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G android.useAndroidX=true android.enableJetifier=true -# This builtInKotlin flag was added automatically by Flutter migrator -android.builtInKotlin=false +android.builtInKotlin=true # This newDsl flag was added automatically by Flutter migrator android.newDsl=false diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index 3c472b9..e4ef43f 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index 44e62bc..ae7019f 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -1,11 +1,25 @@ -include ':app' +pluginManagement { + def flutterSdkPath = { + def properties = new Properties() + file("local.properties").withInputStream { properties.load(it) } + def flutterSdkPath = properties.getProperty("flutter.sdk") + assert flutterSdkPath != null, "flutter.sdk not set in local.properties" + return flutterSdkPath + } + settings.ext.flutterSdkPath = flutterSdkPath() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") -assert localPropertiesFile.exists() -localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } + repositories { + google() + mavenCentral() + gradlePluginPortal() + } +} -def flutterSdkPath = properties.getProperty("flutter.sdk") -assert flutterSdkPath != null, "flutter.sdk not set in local.properties" -apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" +plugins { + id "dev.flutter.flutter-plugin-loader" version "1.0.0" + id "com.android.application" version "8.11.1" apply false +} + +include ":app" From a85265d731539e57c9330f8a82abd5b0548f4d83 Mon Sep 17 00:00:00 2001 From: JTorkk Date: Wed, 17 Jun 2026 15:45:33 +0300 Subject: [PATCH 2/2] build: upgrade Android compile options and JVM target to Java 17 --- example/android/app/build.gradle | 7 +- .../reports/problems/problems-report.html | 663 ++++++++++++++++++ example/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- example/android/settings.gradle | 3 +- 5 files changed, 671 insertions(+), 6 deletions(-) create mode 100644 example/android/build/reports/problems/problems-report.html diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 337f92e..035f95d 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -27,15 +27,16 @@ android { ndkVersion flutter.ndkVersion compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = '17' } + sourceSets { main.java.srcDirs += 'src/main/kotlin' } diff --git a/example/android/build/reports/problems/problems-report.html b/example/android/build/reports/problems/problems-report.html new file mode 100644 index 0000000..643cfbb --- /dev/null +++ b/example/android/build/reports/problems/problems-report.html @@ -0,0 +1,663 @@ + + + + + + + + + + + + + Gradle Configuration Cache + + + +
+ +
+ Loading... +
+ + + + + + diff --git a/example/android/gradle.properties b/example/android/gradle.properties index 574d10e..2b6918b 100644 --- a/example/android/gradle.properties +++ b/example/android/gradle.properties @@ -1,6 +1,6 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G android.useAndroidX=true android.enableJetifier=true -android.builtInKotlin=true +android.builtInKotlin=false # This newDsl flag was added automatically by Flutter migrator android.newDsl=false diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties index e4ef43f..2d428bf 100644 --- a/example/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/android/gradle/wrapper/gradle-wrapper.properties @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-all.zip diff --git a/example/android/settings.gradle b/example/android/settings.gradle index ae7019f..3fe050a 100644 --- a/example/android/settings.gradle +++ b/example/android/settings.gradle @@ -19,7 +19,8 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version "8.11.1" apply false + id "com.android.application" version "9.0.0" apply false + id "org.jetbrains.kotlin.android" version "2.2.20" apply false } include ":app"