Upgrade Gradle and AGP from 7.x to 8.x and use Java 17 #10035
Merged
+44
−28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What is it?
Description of the changes in your PR
Android Studio Flamingo just came out and it asked me to upgrade to Gradle 8.0, so I just ran its upgrade assistant. The version of Gradle it brought me to was 8.0, so I manually set it to 8.1 and it works fine. I also had to manually set the correct
distributionSha256Sum
taken from here.The release notes for Gradle 8.0 are here, for 8.1 here, and release notes for all versions can be found here. I didn't find anything relevant for us in the release notes.
As per Android Gradle Plugin, here are the release notes. The "namespace" breaking change does not affect us as we are already setting
namespace "org.schabi.newpipe"
underandroid {
. Other breaking changes have to do with default values, and an interesting one might be theR
class now having non-final resource IDs by default. Since the app builds fine (I tried to build after agradle clean
), I guess all of these changes have not broken our build.I pushed a third commit adding a JVM argument to
gradle.properties
, otherwise the build will just crash with this strange error message. Previously I avoided this issue by using Gradle with Java 11, but Java 11 is not supported by Gradle 8.1 anymore, and higher Java versions give this error (I tried 17 and 19). I have no idea where this came from and by searching on the internet I only found bug reports about tools we don't use, although the common temporary solution for these kind of messages just seems to be adding--add-opens jdk.compiler/PACKAGE_NAME=ALL-UNNAMED
(wherePACKAGE_NAME
in this case iscom.sun.tools.javac.model
).Now
compileOptions
andkotlinOptions
use JDK 17 (the version shipped with Android Studio by default) instead of JDK 11 to adapt to JDK 11 not being valid anymore. The CI failed for the same reason, so I also updated it to use JDK 17. While I was at it I also upgraded the API 29 Android emulator CI tests to API 33 (Android 13, the latest version), which required changing the sdkmanager target fromdefault
togoogle_apis
since there is no API 33 emulator without Google APIs.APK testing
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
@Isira-Seneviratne can you confirm this is ok?
Due diligence