apache / cordova-android

Apache Cordova Android
https://cordova.apache.org/
Apache License 2.0
3.59k stars 1.52k forks source link

Support AGP 8.1+ by using JVM 17 #1661

Open adjorno opened 7 months ago

adjorno commented 7 months ago

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+:

breautek commented 7 months ago

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

adjorno commented 7 months ago

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!

makouvlei commented 7 months ago

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.

breautek commented 7 months ago

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.

adjorno commented 7 months ago

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

breautek commented 6 months ago

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.