-
Notifications
You must be signed in to change notification settings - Fork 527
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
Upgrade Gradle to 8.9 and AGP to 8.7.3 #5628
Conversation
This moves all Gradle files except app/build.gradle from Groovy to the Kotlin DSL.
The build does not currently work, but it does actually sync. Hopefully this will provide a foundation for upgrading to something that AS Ladybug can support an upgrade with.
This also disables frontend IR (which might break Compose) since it has an incompatibility with the older Kotlin compiler the project is using. It's not obvious why the AGP upgrade triggered this, but the entire build system is quite complex to follow.
This is needed for the next Gradle/AGP upgrade, so doing it a commit early to make it a bit easier.
The build is even more broken at the moment as it's running into a Kotlin compiler issue that may require either upgrading to Kotlin 1.9.x (which would result in a lot of dependency updates) or downgrading AGP (if that's even an option with SDK 34).
I've opened this PR and written up the main PR description comment to try and capture the entirety of:
It seems to me that the only option right now is actually to go ahead with #2747. The cost to migrate Gradle seems far too high (guessing several more days of effort) and far too risky (substantial behavioral skew in dependency upgrades before an imminent release). I don't want to outright remove Gradle to unblock the release, but we will need to merge #5604 and the only way to do that will be to disable Gradle. I'll be sending out another PR to do that, and cite this PR as the primary reason. I do want to admit one specific thing: it may be possible that an earlier version of AGP + Gradle that doesn't require a Kotlin upgrade may work for the SDK 34 fix. I can't be sure of this since the main problem we ran into with the SDK upgrade sounds like it requires a fairly new version of AGP to fix (https://stackoverflow.com/a/76562982/3689782). This may actually be a viable alternative, but I'm not sure that I'm willing to bolt more hacks onto an already very fragile Gradle configuration only to have it fail on us again for a future upgrade. |
## Explanation Fix part of #2747. In order to unblock #5604, this PR disables Gradle in CI completely. This is an extreme mitigation to the issues discovered as part of that PR, but please see #5628 (comment) and that PR's main description for a detailed account of the attempt to migrate to the latest versions of Gradle. It seems that the best path forward both for this upcoming release and long-term is to outright remove Gradle, even though Bazel is not completely developer ready. The alternative (keeping a broken version of Gradle for several months as we migrate dependencies) seems far too disruptive, and not ideal in the long-term since we want to move away from having two build systems, anyway. Please note that I will remove the required Gradle CI checks once the PR is approved (so that it can be merged). This change and the eventual removal of Gradle has been announced in the CLaM chat. We'll need to reach out to specific newer team members in the new year once we actually perform the removal and update corresponding documentation. ## Essential Checklist - [x] The PR title and explanation each start with "Fix #bugnum: " (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".) - [x] Any changes to [scripts/assets](https://github.com/oppia/oppia-android/tree/develop/scripts/assets) files have their rationale included in the PR explanation. - [x] The PR follows the [style guide](https://github.com/oppia/oppia-android/wiki/Coding-style-guide). - [x] The PR does not contain any unnecessary code changes from Android Studio ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#undo-unnecessary-changes)). - [x] The PR is made from a branch that's **not** called "develop" and is up-to-date with "develop". - [ ] The PR is **assigned** to the appropriate reviewers ([reference](https://github.com/oppia/oppia-android/wiki/Guidance-on-submitting-a-PR#clarification-regarding-assignees-and-reviewers-section)). ## For UI-specific PRs only This is an infrastructure only change.
NB: This intentionally not using the PR template since I'm using this PR to document the attempt, not actually submit it.
This PR contains several changes meant to bring AGP (and Gradle) up to the latest necessary for Android Studio Ladybug. The requirement here is not the Android Studio support but, rather, the fact that there seems to be some specific incompatibility with older AGP versions and SDK 34 support (see #5604).
Here's essentially the steps that went into trying to make this work:
app/build.gradle
to the Kotlin DSL from Groovy for better IDE integration and support (since each major version migration has caused a breakage that's very difficult to fix without proper syntax highlighting and API integration--Kotlin is much better for this than Groovy). See ce6db1e. Specific notes:app/build.gradle
to Kotlin, upgrade Gradle from 6.8 to 7.2, and upgrade AGP from 4.2.2 to 7.1.3. This also upgraded the Google Play Services and Firebase Crashlytics plugins, required updating the build to use Java 11 instead of 1.8, required a small change in the model package build to avoid duplicates (per https://stackoverflow.com/q/67265308 and Gradle 7.2 support google/protobuf-gradle-plugin#522 (comment); I struggled a lot with getting this bit working since I couldn't figure out exactly how to customize theprocessResources
step of the module's build pipeline), and some small manifest changes per AGP deprecations. See 058030e. Note that this also disables several required custom work for app builds (such as test sharding) to speed along the attempt to migrate--the intent was to bring this back later in the PR if the migration was successful.kapt
overannotationProcessor
.NB: One or more of these versions also required upgrading to even newer Java versions on the host side for Gradle (which I'm not a fan of--I don't like that the host Java can be different than the build system's configuration since that can result in substantial behavioral skew for team members). I don't remember which one, but I ended up using the embedded JetBrains Java 21 JRE that comes bundled with Android Studio Ladybug.
Note that each Gradle & AGP upgrade was done initially automatically through the Android Studio upgrade plugin (https://developer.android.com/build/agp-upgrade-assistant#run-upgrade-assistant). I started with Bumblebee (the version we require for Gradle work) and later moved to Ladybug once the project was sufficiently updated. The specific Gradle/AGP version bumps were direct recommendations from the upgrader (hence why not every upgrade attempt was a major version). I'm not sure how the upgrader decides on the next version, but I essentially upgraded to the latest that Bumblebee would allow before moving over to Ladybug.
Originally, this migration was thought to be impractical due to a fundamental incompatibility with either the protobuf generation in model or the multi-test configuration being done in app module (I can't remember which, and I couldn't find the old discussions when this was analyzed several years ago). I didn't run into unavoidable problems with either module (though I did not actually verify that the app module tests were working, only non-app tests).
The migration attempt above can be summarized as such:
For context, the upgrade to SDK 34 worked with very little trouble on Bazel despite using the same version of Kotlin and (roughly) the same version dependencies. Also, this upgrade is necessary since the current beta version of the app (0.12) will expire after 31 December 2024, and per https://developer.android.com/google/play/requirements/target-sdk we are required to upgrade to SDK 34 in order to deploy new versions of the app.