From 13b75cdbb473c64bbd4edd9b7d61d98f690172b7 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Mon, 7 Oct 2024 08:22:21 -0400 Subject: [PATCH] Update java to 17 (#167) This updates the version of java used during release builds to 17, the minimum required by our version of AGP. https://developer.android.com/build/releases/gradle-plugin#compatibility It also uses a java toolchain and resolver plugin to automatically download and use the desired version of java, which will hopefully simplify things for others to get spun up on mobile app dev. Reference https://stefma.medium.com/sourcecompatibility-targetcompatibility-and-jvm-toolchains-in-gradle-explained-d2c17c8cff7c for some explanation of toolchains and compatibility targets, and https://docs.gradle.org/current/userguide/toolchains.html#sec:provisioning for notes about automatic provisioning via toolchain. --- .github/workflows/release.yml | 2 +- android/app/build.gradle | 15 ++++++--------- android/settings.gradle | 1 + 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ae18d24..1f2d192 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - uses: actions/setup-java@v2 with: distribution: 'zulu' - java-version: '11' + java-version: '17' - name: Install flutter uses: subosito/flutter-action@v2 diff --git a/android/app/build.gradle b/android/app/build.gradle index ed72850..1f8ad57 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -28,15 +28,6 @@ android { compileSdkVersion 34 - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 - } - sourceSets { main.java.srcDirs += 'src/main/kotlin' } @@ -72,6 +63,12 @@ android { } } +java { + toolchain { + languageVersion = JavaLanguageVersion.of(17) + } +} + flutter { source '../..' } diff --git a/android/settings.gradle b/android/settings.gradle index 3192560..3ff10ee 100644 --- a/android/settings.gradle +++ b/android/settings.gradle @@ -17,6 +17,7 @@ pluginManagement { } plugins { + id "org.gradle.toolchains.foojay-resolver-convention" version "0.8.0" id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version '8.6.1' apply false id "org.jetbrains.kotlin.android" version "2.0.20" apply false