chore(android): remove targetSdkVersion declarations#8507
Conversation
jcesarmobile
left a comment
There was a problem hiding this comment.
I think we should keep the targetSdkVersion = 37 in variables.gradle, since it's just a variable declaration and not an usage, just in case the user has plugins that haven't been updated yet and they still have something like targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36, so, since targetSdkVersion variable would not be there if we remove it, it will be set to 36.
Good point, reverting that one. |
Description
Remove the explicit
targetSdkVersiondeclarations from Capacitor's Android library modules, the Android template, and the Cordova plugins template. AGP 9 inferstargetSdkVersionfromcompileSdkVersionwhen unset, so the explicit declarations were redundant.Reference: RMET-5256
Change Type
Rationale / Problems Fixed
AGP 9.0 changed the default behavior so that
targetSdkVersionis inferred fromcompileSdkVersionwhen not explicitly set (via theandroid.sdk.defaultTargetSdkToCompileSdkIfUnsetproperty, which flippedto
trueby default). With both values aligned at37today, the explicit declarations were noise. Removing them simplifies the build configuration without any change in build output, the inferred value matches the previously declared one.This is a follow-up from the AGP 9 / Gradle 9 upgrade (#8498).
Tests or Reproductions
./gradlew assembleDebuginandroid/: BUILD SUCCESSFUL./gradlew :capacitor-android:testDebugUnitTest :capacitor-cordova-android:testDebugUnitTest: BUILD SUCCESSFULnpm run buildincli/: regenerated templates tarballs successfully./gradlew assembleDebug: BUILD SUCCESSFUL, and confirmed the merged manifest reportsandroid:targetSdkVersion="37"(inferred fromcompileSdkVersion)targetSdkVersionback tovariables.gradleandapp/build.gradlecorrectly sets the explicit value in the merged manifest (verified withtargetSdkVersion = 35)Platforms Affected