cordova-android icon indicating copy to clipboard operation
cordova-android copied to clipboard

Support AGP 8.1+ by using JVM 17

Open adjorno opened this issue 1 year ago • 6 comments

Feature Request

Support latest build tool set like Gradle 8.2+, AGP 8.1+, Kotlin 1.9 (already addressed in https://github.com/apache/cordova-android/issues/1642)

Motivation Behind Feature

Starting from AGP 8.1.0 Android ships with JDK 17 bytecode. https://developer.android.com/build/releases/gradle-plugin#8-1-0

Current cordova-android build.gradle template hardcodes the JVM toolchain to the version 1.8 which is incompatible with the latest AGP plugin:

android {
...
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
...

Feature Description

There are multiple ways to support AGP 8.1+:

  • Make JVM version customisable so a developer can set it from config.xml (a bit more work, I am not sure whether it's going to be beneficial). Or
  • Make a hard switch to JVM 17:
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

adjorno avatar Sep 05 '23 12:09 adjorno

AGP 8 support will be a cordova-android 13.x thing

Current cordova-android build.gradle template hardcodes the JVM toolchain to the version 1.8 which is incompatible with the latest AGP plugin:

I don't think this is true, because in my non-cordova projects I'm using the AGP betas with AS Hedgehog and the project it generates me still uses java 8 here and it compiles and runs fine, unless something changed recently? Currently I am using source/target compat of java 8 in my gradle on AGP 8.2 / AS Hedghehog / running JDK 17.

But regardless, AGP 8 support will be required by the API 34 toolset, so it is planned.

Reference in case we decide to update the sourceCompatibility anyway: https://developer.android.com/build/jdks#groovy

breautek avatar Sep 05 '23 13:09 breautek

Indeed, I should've mentioned the usage of API 34.

Nice to here that it's going to be supported in Cordova 13+. Thanks for the swift reply!

adjorno avatar Sep 05 '23 13:09 adjorno

Is there a practical workaround until AGP 8.1+ is added to the cordova-android 13 release? Google Play has indicated no updates will be able to be released for existing apps targeting AGP <33 after Nov 1.

makouvlei avatar Sep 13 '23 16:09 makouvlei

Is there a practical workaround until AGP 8.1+ is added to the cordova-android 13 release? Google Play has indicated no updates will be able to be released for existing apps targeting AGP <33 after Nov 1.

cordova-android@12 supports API 33, you don't need to wait for AGP 8.1 to target API 33.

AGP 8+ will be a requirement for API 34, which will likely only be a target requirement end of August of next year, assuming that Google maintains their typical release schedule.

breautek avatar Sep 13 '23 16:09 breautek

I just added an extra step to my CI/CD pipelines to replace VERSION_1_8 with VERSION_17 by running a bash script.

adjorno avatar Sep 13 '23 16:09 adjorno

PR #1678 is a draft proposal for API 34 support. It won't be merged in anytime soon since I believe we want to make a 12.1.0 release first. Additionally, it is using AGP 8.2 RC and I'd like for google to make a formal final release as well, but perhaps it can be tested and get some early feedback.

breautek avatar Oct 21 '23 01:10 breautek