Skip to content

feat!: API 31 support#1410

Merged
erisu merged 3 commits intoapache:masterfrom
breautek:API31
Apr 17, 2022
Merged

feat!: API 31 support#1410
erisu merged 3 commits intoapache:masterfrom
breautek:API31

Conversation

@breautek
Copy link
Copy Markdown
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
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 5, 2022

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.20%. Comparing base (6d3ce21) to head (6b766d1).
⚠️ Report is 190 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1410   +/-   ##
=======================================
  Coverage   73.20%   73.20%           
=======================================
  Files          21       21           
  Lines        1646     1646           
=======================================
  Hits         1205     1205           
  Misses        441      441           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@erisu erisu changed the title feat: API 31 support feat!: API 31 support Apr 5, 2022
@erisu erisu merged commit 5704ef9 into apache:master 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants