Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: API 31 support #1410

Merged
merged 3 commits into from Apr 17, 2022
Merged

feat!: API 31 support #1410

merged 3 commits into from Apr 17, 2022

Conversation

breautek
Copy link
Contributor

@breautek breautek commented Apr 4, 2022

Platforms affected

Android

Motivation and Context

Changes necessary to support API 31.

Description

Version updates:

SDK Version 30 -> 31
Gradle 7.1.1 -> 7.4.2
AGP 4.2.2 -> 7.1.0
Build Tools 30.0.3 -> 31.0.0

Testing

Ran hello cordova app in emulator. Ran npm test successfully.

Other remarks

To test this PR, requires the following changes:

With AGP 7.x, Java 11 is now required. Ensure that JAVA_HOME is set to a jdk 11 path and PATH has jdk binaries.

Further instructions assumes that you have ANDROID_SDK_ROOT path set appropriately. If you still use the older ANDROID_HOME, then $ANDROID_SDK_ROOT should be substituted with $ANDROID_HOME

With this change, cmdline-tools package is required. I tesed with cmdline-tools 6.0. If you attempt to use the old tools from $ANDROID_SDK_ROOT/tools/bin, it will crash. You will need to add $ANDROID_SDK_ROOT/cmdline-tools/<version>/bin to your PATH variable.

If you have $ANDROID_SDK_ROOT/tools/bin path in your PATH variable, it should be removed.

API 31 requires build tools 31. Use Android Studio's SDK Manager to install build tools 31.0.0. And ensure that $ANDROID_SDK_ROOT/build-tools/31.0.0 is in your PATH variable.

These things probably should be mentioned in our release announcement.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@breautek breautek added this to the 11.0.0 milestone Apr 4, 2022
@breautek breautek added this to To Do in Release Plan - 11.0.0 via automation Apr 4, 2022
@codecov-commenter
Copy link

codecov-commenter commented Apr 5, 2022

Codecov Report

Merging #1410 (6b766d1) into master (6d3ce21) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1410   +/-   ##
=======================================
  Coverage   73.20%   73.20%           
=======================================
  Files          21       21           
  Lines        1646     1646           
=======================================
  Hits         1205     1205           
  Misses        441      441           
Impacted Files Coverage Δ
lib/env/java.js 98.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d3ce21...6b766d1. Read the comment docs.

@erisu erisu changed the title feat: API 31 support feat!: API 31 support Apr 5, 2022
Release Plan - 11.0.0 automation moved this from To Do to In Progress Apr 5, 2022
@erisu erisu merged commit 5704ef9 into apache:master Apr 17, 2022
Release Plan - 11.0.0 automation moved this from In Progress to Done Apr 17, 2022
wedgberto pushed a commit to wedgberto/cordova-android that referenced this pull request May 17, 2022
* feat(breaking): API 31 support
* ci: bump actions/setup-java@3 w/ java 11
* ci: set setup-java distribution to adopt

Co-authored-by: Erisu <erisu@apache.org>
@ath0mas
Copy link
Contributor

ath0mas commented Jul 23, 2022

Thanks for v11 💯 !!

Just to let you know that the AGP 4.2.2 -> 7.1.0 is partly blocking for IntelliJ IDEA users for now (not Android Studio).
When opening the generated Android native project, an error during Sync prevents further loading because of AGP version incompatibility.

This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 2021.2.1 or newer.

Details:

  • IntelliJ IDEA latest stable version is 2022.1.4
  • its Android plugin is mapped to Android Studio, and current version is bundled 2020.3.1 Final.221.6008.13 (corresponding to Arctic Fox)
  • in practice and given the compatibility table, AGP can only be 7.0 at max for now to work properly
  • this PR sets v7.1, requiring Bumblebee | 2021.1.1, and was followed by an update to v7.2 in feat: Update gradle plugin version #1446, requiring Chipmunk | 2021.2.1

Workarounds (see their issue tracker):

please use IDEA 2022.2 or downgrade AGP to version 7.0.x

  • edit framework/cdv-gradle-config-defaults.json to force AGP_VERSION to, let say, 7.0.1 ; and force reload/Sync
  • try to update IntelliJ IDEA to preview builds of 2022.2 (currently RC)

@erisu
Copy link
Member

erisu commented Jul 23, 2022

@ath0mas Have you tried setting the preference flag AndroidGradlePluginVersion instead of editing the default file directly?

<preference name="AndroidGradlePluginVersion" value="7.0.1" />

Then run CLI command: cordova prepare android

This will update the platforms/android/cdv-gradle-config.json that is read by the project. Then you should be able to force reload/Sync.

I guess it depends on the use case, but I think the above config is enough for most cases?

@ath0mas
Copy link
Contributor

ath0mas commented Jul 24, 2022

@erisu You are correct, your solution works great too! Thanks 👍

I was not aware of this preference as it is not documented.
See https://cordova.apache.org/docs/en/11.x/config_ref/index.html#preference.
I can only find it in cordova-android source code.

@breautek
Copy link
Contributor Author

I wasn't aware there can be some restrictions in the gradle version + android studio, I figured they'd support at least a given major with any minor/patch version. Thanks for the compatibility table, this is definitely good to know.

Regarding the preferences, yah there are a number of preferences that was added (back in v10 if I recall correctly) without actually being documented. Some of these preferences will very likely break builds if you use something other than the default configured. Cordova is only ever tested against the default configuration for build tools, AGP version, etc... I think we can document these but I think some of these new preferences needs to be stressed that they are for advanced usage / cordova development only

I'll create a issue on the docs repo as a reminder. Eventually I'll get to it, if someone else doesn't get to it first. PRs are welcome.

mashoodpv pushed a commit to mashoodpv/cordova-android that referenced this pull request Dec 13, 2022
* feat(breaking): API 31 support
* ci: bump actions/setup-java@3 w/ java 11
* ci: set setup-java distribution to adopt

Co-authored-by: Erisu <erisu@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants