From 3b9ab5f7cfaebb42ce231f0a28fbe8ef9f5cbbce Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 21 Mar 2024 14:37:44 +0000 Subject: [PATCH 01/16] bump Gradle to 8.6 --- uni/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uni/android/gradle/wrapper/gradle-wrapper.properties b/uni/android/gradle/wrapper/gradle-wrapper.properties index 89e56bdb6..628d33c21 100644 --- a/uni/android/gradle/wrapper/gradle-wrapper.properties +++ b/uni/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip From 626e371f67c44bb93afc39c06c6bac79f1fc5e6b Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 21 Mar 2024 14:51:43 +0000 Subject: [PATCH 02/16] update Kotlin, AGP, and migrate Gradle buildscripts to a modern style --- uni/android/app/build.gradle | 60 ++++++++++++++++++------------------ uni/android/build.gradle | 19 ++---------- uni/android/settings.gradle | 30 +++++++++++++----- 3 files changed, 54 insertions(+), 55 deletions(-) diff --git a/uni/android/app/build.gradle b/uni/android/app/build.gradle index abcdccc32..ad7afbcdf 100644 --- a/uni/android/app/build.gradle +++ b/uni/android/app/build.gradle @@ -1,71 +1,67 @@ +plugins { + id "com.android.application" + id "dev.flutter.flutter-gradle-plugin" + id "org.jetbrains.kotlin.android" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + 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') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - def keystoreProperties = new Properties() -def keystorePropertiesFile = rootProject.file('key.properties') +def keystorePropertiesFile = rootProject.file("key.properties") if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android { - if (project.android.hasProperty("namespace")) { - namespace "pt.up.fe.ni.uni" - } + namespace "pt.up.fe.ni.uni" - compileSdkVersion 34 // default is flutter.compileSdkVersion + compileSdkVersion 34 ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 + coreLibraryDesugaringEnabled true } kotlinOptions { - jvmTarget = '1.8' + jvmTarget = "1.8" } sourceSets { - main.java.srcDirs += 'src/main/kotlin' + main.java.srcDirs += "src/main/kotlin" } defaultConfig { applicationId "pt.up.fe.ni.uni" - minSdkVersion 21 // default is flutter.minSdkVersion - targetSdkVersion 34 // default is flutter.targetSdkVersion + minSdkVersion 21 + targetSdkVersion 34 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } signingConfigs { release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null - storePassword keystoreProperties['storePassword'] + keyAlias keystoreProperties["keyAlias"] + keyPassword keystoreProperties["keyPassword"] + storeFile keystoreProperties["storeFile"] ? file(keystoreProperties["storeFile"]) : null + storePassword keystoreProperties["storePassword"] } } @@ -77,9 +73,13 @@ android { } flutter { - source '../..' + source "../.." } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + // The following 3 lines are a workaround for the Flutter issue. + // Learn more: https://github.com/flutter/flutter/issues/110658 + implementation "androidx.window:window:1.0.0" + implementation "androidx.window:window-java:1.0.0" + coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.2.2" } diff --git a/uni/android/build.gradle b/uni/android/build.gradle index db859f3a9..d2ffbffa4 100644 --- a/uni/android/build.gradle +++ b/uni/android/build.gradle @@ -1,18 +1,3 @@ -buildscript { - ext.kotlin_version = '1.9.0' - ext.android_plugin_version = '8.0.0' - - repositories { - google() - mavenCentral() - } - - dependencies { - classpath "com.android.tools.build:gradle:$android_plugin_version" - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - allprojects { repositories { google() @@ -20,12 +5,12 @@ allprojects { } } -rootProject.buildDir = '../build' +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { diff --git a/uni/android/settings.gradle b/uni/android/settings.gradle index 44e62bcf0..82f7f6e9a 100644 --- a/uni/android/settings.gradle +++ b/uni/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 + }() -def localPropertiesFile = new File(rootProject.projectDir, "local.properties") -def properties = new Properties() + includeBuild("$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" + id "com.android.application" version "8.3.1" apply false + id "org.jetbrains.kotlin.android" version "1.9.23" apply false +} + +include ":app" From 8a12457648111775d9ea2c0ae518efb37e02eb7a Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 21 Mar 2024 14:51:54 +0000 Subject: [PATCH 03/16] remove deprecated `package` attribute from AndroidManifests --- uni/android/app/src/debug/AndroidManifest.xml | 3 +-- uni/android/app/src/main/AndroidManifest.xml | 3 +-- uni/android/app/src/profile/AndroidManifest.xml | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/uni/android/app/src/debug/AndroidManifest.xml b/uni/android/app/src/debug/AndroidManifest.xml index 205191a23..399f6981d 100644 --- a/uni/android/app/src/debug/AndroidManifest.xml +++ b/uni/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,4 @@ - +