Skip to content

fix(android): make vendored gradle scripts work with Gradle 9.x and AGP 9 - #9

Merged
farfromrefug merged 1 commit into
mainfrom
fix/gradle-9-vendor-scripts
Oct 17, 2026
Merged

farfromrefug merged 1 commit into
mainfrom
fix/gradle-9-vendor-scripts

Conversation

@farfromrefug

Copy link
Copy Markdown
Collaborator

Summary

  • Fix the vendored gradle-app / gradle-plugin scripts for Gradle 9.x and AGP 9: replace the removed Project.exec {}, make BuildToolTask abstract, drop groovy-all 3.0.8 and jcenter(), and only apply kotlin-android below AGP 9.
  • Keep the generated R.jar task dependency when extracting compile classpath jars (Gradle now flags it as an implicit dependency).
  • Only require validateSigning for the build type being built, so debug runs no longer need a release keystore.

Testing

Built a NativeScript app with Gradle 9.7.1 + AGP 9.4.1 (android.newDsl=false): ns prepare, plugin AARs, debug APK and a signed release APK with R8 and JS bytecode compile all succeed. Gradle 9.7.1 needs AGP 9 (AGP 8.x uses Gradle internal APIs removed in 9.6).
Not verified: Gradle 8.x builds with these scripts (the kotlin-android branch below AGP 9 is unchanged logic), iOS.

Needed by the matching oss-weather PR that moves the app to Gradle 9.7.1.

…GP 9

Gradle 9 and AGP 9 removed or tightened APIs the vendored app and plugin
build scripts relied on:

- Project.exec {} is gone: use an injected ExecOperations (bytecode step)
- subclasses of JavaExec must be abstract (BuildToolTask)
- the kotlin-android plugin conflicts with AGP 9 built-in Kotlin: only
  apply it below AGP 9
- groovy-all 3.0.8 on the plugin build classpath clashes with Gradle's
  Groovy 4, and jcenter() no longer exists: remove both
- compile classpath jars were declared as plain File inputs, so Gradle
  flagged the generated R.jar as an implicit dependency: pass the
  filtered FileCollection to keep its task dependencies
- only require validateSigning for the build type being built, so a
  debug run does not need a release keystore

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@farfromrefug
farfromrefug marked this pull request as ready for review October 17, 2026 12:59
@farfromrefug
farfromrefug merged commit 8e601ff into main Oct 17, 2026
7 of 11 checks passed
farfromrefug added a commit to ossappscollective/oss-weather that referenced this pull request Oct 17, 2026
Gradle 9.6+ removed the internal APIs every AGP 8.x relies on, so 9.7.1
requires AGP 9. Needs the matching nativescript-cli vendor script fixes
(Akylas/nativescript-cli#9).

- Gradle 9.7.1, AGP 9.4.1, androidx baselineprofile plugin 1.5.0
- android.newDsl=false: the build scripts still use applicationVariants,
  which the AGP 9 DSL removes (temporary opt-out, gone in AGP 10)
- run the gradle.properties merge hook before prepareNativeApp, so the
  licences hook (which runs gradle) already sees android.newDsl
- drop the kotlin-android plugin (AGP 9 built-in Kotlin) and the removed
  kotlinOptions, replace Project.exec with ExecOperations
- enable the Gradle build cache (clean release build 35s -> 17s)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

1 participant