From 91933906095f28d019131532da696967e4d5df14 Mon Sep 17 00:00:00 2001 From: Xavier Paquet-Rapold <80051842+XavierPaquet-Rapold@users.noreply.github.com> Date: Sat, 16 Nov 2024 09:37:20 -0500 Subject: [PATCH] Upgrade gradle to 8.9 (#1093) * Upgrade Android project * Upgrade gradle to 8.9 * Fix metadata file * Update workflows * Downgrade java version * [BOT] Applying pod update. * [BOT] Applying pod update. --------- Co-authored-by: XavierPaquet-Rapold --- .github/composite/ci-build/action.yaml | 5 +- .github/workflows/dev-workflow.yaml | 1 - .github/workflows/master-workflow.yaml | 1 - .metadata | 14 ++-- android/.gitignore | 6 ++ android/app/build.gradle | 70 ++++++------------- android/app/src/debug/AndroidManifest.xml | 3 +- .../etsmtl/applets/etsmobile/MainActivity.kt | 3 +- .../app/src/main/res/values-night/styles.xml | 18 +++++ android/app/src/main/res/values/styles.xml | 12 ++-- android/app/src/profile/AndroidManifest.xml | 3 +- android/build.gradle | 13 +--- android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 2 +- android/settings.gradle | 33 ++++++--- 15 files changed, 92 insertions(+), 94 deletions(-) create mode 100644 android/app/src/main/res/values-night/styles.xml diff --git a/.github/composite/ci-build/action.yaml b/.github/composite/ci-build/action.yaml index 755f3028b..bd082dba0 100644 --- a/.github/composite/ci-build/action.yaml +++ b/.github/composite/ci-build/action.yaml @@ -15,9 +15,6 @@ inputs: asset-extension: required: true default: zip - github-api-token: - description: the Github API token - required: true app-name: required: true app-path: @@ -30,7 +27,7 @@ runs: steps: - name: Build the application shell: bash - run: flutter build -v ${{ inputs.build-target }} ${{ inputs.build-args }} --release --dart-define=GH_API_TOKEN=${{ inputs.github-api-token }} + run: flutter build -v ${{ inputs.build-target }} ${{ inputs.build-args }} --release env: MAPS_API_KEY: ${{ inputs.maps-api-key }} diff --git a/.github/workflows/dev-workflow.yaml b/.github/workflows/dev-workflow.yaml index da6368b61..c2330ac45 100644 --- a/.github/workflows/dev-workflow.yaml +++ b/.github/workflows/dev-workflow.yaml @@ -96,7 +96,6 @@ jobs: build-path: ${{ matrix.build_path }} asset-extension: ${{ matrix.asset_extension }} asset-content-type: ${{ matrix.asset_content_type }} - github-api-token: ${{ secrets.GH_API_TOKEN }} app-name: ${{ env.APP_NAME }} app-path: ${{ github.workspace }}/${{ env.APP_NAME }}_${{ matrix.target }}.${{ matrix.asset_extension }} maps-api-key: ${{ secrets.MAPS_API_KEY }} diff --git a/.github/workflows/master-workflow.yaml b/.github/workflows/master-workflow.yaml index 5c1c825f1..095e66845 100644 --- a/.github/workflows/master-workflow.yaml +++ b/.github/workflows/master-workflow.yaml @@ -116,7 +116,6 @@ jobs: build-path: ${{ matrix.build_path }} asset-extension: ${{ matrix.asset_extension }} asset-content-type: ${{ matrix.asset_content_type }} - github-api-token: ${{ secrets.GH_API_TOKEN }} app-name: ${{ env.APP_NAME }} app-path: ${{ github.workspace }}/${{ env.APP_NAME }}_${{ matrix.target }}.${{ matrix.asset_extension }} maps-api-key: ${{ secrets.MAPS_API_KEY }} diff --git a/.metadata b/.metadata index e27f5ccf8..e7e0854a8 100644 --- a/.metadata +++ b/.metadata @@ -1,11 +1,11 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled. +# This file should be version controlled and should not be manually edited. version: - revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 - channel: stable + revision: "603104015dd692ea3403755b55d07813d5cf8965" + channel: "stable" project_type: app @@ -13,11 +13,11 @@ project_type: app migration: platforms: - platform: root - create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 - base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 + create_revision: 603104015dd692ea3403755b55d07813d5cf8965 + base_revision: 603104015dd692ea3403755b55d07813d5cf8965 - platform: android - create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 - base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 + create_revision: 603104015dd692ea3403755b55d07813d5cf8965 + base_revision: 603104015dd692ea3403755b55d07813d5cf8965 - platform: ios create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 diff --git a/android/.gitignore b/android/.gitignore index bc2100d8f..55afd919c 100644 --- a/android/.gitignore +++ b/android/.gitignore @@ -5,3 +5,9 @@ gradle-wrapper.jar /gradlew.bat /local.properties GeneratedPluginRegistrant.java + +# Remember to never publicly share your keystore. +# See https://flutter.dev/to/reference-keystore +key.properties +**/*.keystore +**/*.jks diff --git a/android/app/build.gradle b/android/app/build.gradle index c1604fe80..c7878c4e8 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,54 +1,37 @@ -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.") +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" + id 'com.google.gms.google-services' + id 'com.google.firebase.crashlytics' } - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') -if (flutterVersionCode == null) { - flutterVersionCode = '1' -} - -def flutterVersionName = localProperties.getProperty('flutter.versionName') -if (flutterVersionName == null) { - flutterVersionName = '1.0' -} - def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('keystore.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } -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' -apply plugin: 'com.google.firebase.crashlytics' - android { - compileSdkVersion flutter.targetSdkVersion - ndkVersion "26.3.11579264" + namespace = "ca.etsmtl.applets.etsmobile" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion - sourceSets { - main.java.srcDirs += 'src/main/kotlin' + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } + kotlinOptions { + jvmTarget = JavaVersion.VERSION_17 + } defaultConfig { - applicationId "ca.etsmtl.applets.etsmobile" - minSdkVersion flutter.minSdkVersion - targetSdkVersion flutter.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - multiDexEnabled true + applicationId = "ca.etsmtl.applets.etsmobile" + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutter.versionCode + versionName = flutter.versionName manifestPlaceholders += [mapsApiKey: "$System.env.MAPS_API_KEY"] } @@ -80,7 +63,6 @@ android { ext.alwaysUpdateBuildId = false } } - namespace 'ca.etsmtl.applets.etsmobile' lint { checkDependencies true disable 'InvalidPackage' @@ -88,13 +70,5 @@ android { } flutter { - source '../..' + source = "../.." } - -dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'com.android.support:multidex:1.0.3' - implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.2.0' -} \ No newline at end of file diff --git a/android/app/src/debug/AndroidManifest.xml b/android/app/src/debug/AndroidManifest.xml index f880684a6..399f6981d 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,6 @@ - diff --git a/android/app/src/main/kotlin/ca/etsmtl/applets/etsmobile/MainActivity.kt b/android/app/src/main/kotlin/ca/etsmtl/applets/etsmobile/MainActivity.kt index 4346fc2e9..817611866 100644 --- a/android/app/src/main/kotlin/ca/etsmtl/applets/etsmobile/MainActivity.kt +++ b/android/app/src/main/kotlin/ca/etsmtl/applets/etsmobile/MainActivity.kt @@ -2,5 +2,4 @@ package ca.etsmtl.applets.etsmobile import io.flutter.embedding.android.FlutterActivity -class MainActivity : FlutterActivity() { -} \ No newline at end of file +class MainActivity: FlutterActivity() diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 000000000..06952be74 --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/android/app/src/main/res/values/styles.xml b/android/app/src/main/res/values/styles.xml index 1f83a33fd..cb1ef8805 100644 --- a/android/app/src/main/res/values/styles.xml +++ b/android/app/src/main/res/values/styles.xml @@ -1,18 +1,18 @@ - - - diff --git a/android/app/src/profile/AndroidManifest.xml b/android/app/src/profile/AndroidManifest.xml index f880684a6..399f6981d 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,6 @@ - diff --git a/android/build.gradle b/android/build.gradle index 2d132cc5f..663c1eb51 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.7.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.4.2' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.7.1' @@ -21,19 +21,12 @@ allprojects { } } -rootProject.buildDir = '../build' -subprojects { - afterEvaluate { - android { - compileSdkVersion 34 - } - } -} +rootProject.buildDir = "../build" subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { - project.evaluationDependsOn(':app') + project.evaluationDependsOn(":app") } tasks.register("clean", Delete) { diff --git a/android/gradle.properties b/android/gradle.properties index 19f632fc6..7496dc98c 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,4 +1,4 @@ -org.gradle.jvmargs=-Xmx1536M -XX:+UseParallelGC +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=2G -XX:+HeapDumpOnOutOfMemoryError android.useAndroidX=true android.enableJetifier=true extra-gen-snapshot-options=--obfuscate diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 3c472b99c..348c409ea 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/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.9-all.zip diff --git a/android/settings.gradle b/android/settings.gradle index a8ea5755e..c73e3b40a 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -1,14 +1,25 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. -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" version "1.0.0" + id "com.android.application" version '8.7.2' apply false + id "org.jetbrains.kotlin.android" version "1.8.22" apply false +} + +include ":app"