Skip to content

fix(android): avoid implicit parent project property lookup deprecated in Gradle 9 - #8731

Merged
andredestro merged 1 commit into
mainfrom
fix/RMET-5591/gradle-implicit-property-lookup
Nov 20, 2026
Merged

andredestro merged 1 commit into
mainfrom
fix/RMET-5591/gradle-implicit-property-lookup

Conversation

@andredestro

Copy link
Copy Markdown
Contributor

Description

On Gradle 9.8, an app shows "Implicit lookup of properties in parent projects has been deprecated. This will fail with an error in Gradle 10." for Capacitor's own build files, once per variable the app sets in variables.gradle.

The library build.gradle files read overrides with project.hasProperty('x') ? rootProject.ext.x : default. Called on the subproject, hasProperty() only finds x by falling back to the root project, and that fallback is what Gradle deprecated. The warning only shows up inside an app, because the library repo itself never defines these variables.

This PR calls hasProperty() on rootProject, which is where the value is read from anyway, so the behavior is the same:

  • android/capacitor/build.gradle (11 lines)
  • android/capacitor-cordova/build.gradle (4 lines)
  • capacitor-cordova-android-plugins/build.gradle, the template the CLI copies into apps (4 lines)
  • cli/src/android/update.ts, the cdvMinSdkVersion line written to cordova.variables.gradle, which is applied from :app

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

https://outsystemsrd.atlassian.net/browse/RMET-5591
https://docs.gradle.org/9.8.2/userguide/upgrading_version_9.html#deprecated_implicit_lookup_in_parent_projects

Platforms Affected

  • Android
  • iOS
  • Web

Tests

App: capacitor-testapp plus one Cordova plugin (cordova-plugin-device), so the two Cordova modules are included. Gradle 9.8.2, ./gradlew assembleDebug --warning-mode all. @capacitor/android linked to this branch and cap sync android run with this branch's CLI, so the generated files come from the new code.

Before After
capacitor/build.gradle 11 0
capacitor-cordova/build.gradle 4 0
capacitor-cordova-android-plugins/build.gradle 4 0
cordova.variables.gradle 2 0
Plugins from capacitor-plugins (not in this PR) 148 148

App overrides still apply. variables.gradle set values that differ from the library defaults, and an init script printed the effective values for :app, :capacitor-android, :capacitor-cordova-android and :capacitor-cordova-android-plugins. They are the same before and after: minSdk=27 (default 26), cdvMinSdkVersion=27, cordovaAndroidVersion=15.0.0 (default 15.1.0), androidxAppCompatVersion=1.7.1 (default 1.8.0). compileSdk is not covered by this check, because the app uses the same value as the default.

With Gradle 9.5.1 there are no warnings either before or after.

npm test -w cli passes (507 tests). prettier --check and eslint pass on update.ts. I did not run npm run verify -w android locally; CI covers it.

Notes / Comments

The same lines exist on next. The plugins in capacitor-plugins and the plugin template in create-capacitor-plugin use the same pattern and will get separate PRs.

…d in Gradle 9

The library build.gradle files read app overrides with
project.hasProperty('x') ? rootProject.ext.x : default. hasProperty() on a
subproject only finds the value by falling back to the root project, which
Gradle 9 deprecates and Gradle 10 will turn into an error.

Call hasProperty() on rootProject instead, which is where the value is read
from anyway. Same for the cdvMinSdkVersion line the CLI writes to
cordova.variables.gradle.
This was referenced Nov 19, 2026
@markemer

Copy link
Copy Markdown
Member

This also should fix: https://outsystemsrd.atlassian.net/browse/RMET-5590

@andredestro
andredestro merged commit 31115e0 into main Nov 20, 2026
7 checks passed
@andredestro
andredestro deleted the fix/RMET-5591/gradle-implicit-property-lookup branch November 20, 2026 11:22
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.

3 participants