Set minSdk 21 so consumers stop inheriting implied permissions - #1
Open
blackbbc wants to merge 1 commit into
Open
Set minSdk 21 so consumers stop inheriting implied permissions#1blackbbc wants to merge 1 commit into
blackbbc wants to merge 1 commit into
Conversation
defaultConfig had no minSdk, so AGP wrote minSdkVersion="1" into the AAR manifest. AGP also strips targetSdkVersion from library manifests entirely (setting defaultConfig.targetSdk or declaring it in the source manifest are both no-ops), so consumers fall back to targetSdk == minSdk == 1. That triggers the manifest merger's implied-permission rules in every app depending on this AAR: - targetSdk < 4 -> READ_PHONE_STATE - targetSdk < 16 + app requests WRITE_EXTERNAL_STORAGE -> READ_EXTERNAL_STORAGE The implied READ_EXTERNAL_STORAGE carries no maxSdkVersion, so it applies at every API level even when the app caps its own WRITE_EXTERNAL_STORAGE. Bumped to 1.6.1 rather than reusing 1.6, since the artifact content changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
defaultConfighad nominSdk, so AGP wroteminSdkVersion="1"into the published AAR manifest:AGP also strips
targetSdkVersionfrom library manifests entirely — settingdefaultConfig.targetSdkand declaring<uses-sdk android:targetSdkVersion="34"/>in the source manifest are both no-ops (verified against AGP 8.6). So consumers fall back totargetSdk == minSdk == 1.That trips the manifest merger's implied-permission rules in every app depending on this AAR:
targetSdk < 4READ_PHONE_STATEtargetSdk < 16+ app requestsWRITE_EXTERNAL_STORAGEREAD_EXTERNAL_STORAGEThe implied
READ_EXTERNAL_STORAGEcarries nomaxSdkVersion, so it applies at every API level even when the consuming app caps its ownWRITE_EXTERNAL_STORAGE(e.g.android:maxSdkVersion="28").Fix
Set
minSdk 21. WithtargetSdkVersionabsent from the manifest, Android semantics fall targetSdk back to minSdk — 21 clears both the< 4and< 16thresholds.minSdkis the only lever that works here; the comment inbuild.gradlerecords why, so nobody deletes it as redundant.Verification
New AAR manifest:
Dropped into a downstream consumer (XMind bagel,
minSdk 26, declaresWRITE_EXTERNAL_STORAGEwithmaxSdkVersion="28") and re-ran the manifest merge.IMPLIEDentries in the merger report went from 2 to 0; bothREAD_EXTERNAL_STORAGEandREAD_PHONE_STATEdisappeared from the merged manifest, with no other permission affected.Version bumped to 1.6.1 rather than reusing 1.6, since the artifact content changes.