-
Notifications
You must be signed in to change notification settings - Fork 950
fix(android): install camelCase flavor APKs from output-metadata.json - #2853
Open
cpruijsen wants to merge 1 commit into
Open
fix(android): install camelCase flavor APKs from output-metadata.json #2853cpruijsen wants to merge 1 commit into
cpruijsen wants to merge 1 commit into
Conversation
Splitting --mode on capitals cannot distinguish a single camelCase flavor from multiple flavor dimensions, so prefer the filename AGP already wrote.
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.
Summary
run-android --device/--list-devices/--interactiveinstalls theoutputFilenamed in AGPoutput-metadata.jsoninstead of guessing a hyphenated filename from--mode. Gradle writesapp-stagingInternal-debug.apkfor a camelCase product flavor (for examplestagingInternalDebug); the CLI looked forapp-staging-internal-debug.apkbecause it derived the filename by splitting--modeon capitals and joining with hyphens. The output directory is already correct (apk/stagingInternal/debug); only the filename was wrong.That split cannot be made correct for every project:
acmeStagingDebugis either one flavor namedacmeStagingor the flavorsacmeandstaging, and those produce different filenames in the same directory. #2324 / #2762 already fixed the directory; the CLI still guessed the filename.output-metadata.jsonis the file captured on AGP 8.13.0 in the issue, and later used successfully via a local patch on 20.2.0. ABI splits follow the device CPU list rather than metadata array order. The previous name guess remains as a fallback when the metadata file is missing or the listed APK is not on disk.Decided: read
output-metadata.jsonfirst, keep the existing guess as fallback. Alternative: try both the hyphenated and unsplit flavor names as candidate filenames. The two Gradle layouts cannot be told apart from--modealone; the reporter already verified the metadata approach on 20.2.0 with--list-devicesand--device. Can switch to the dual-candidate heuristic if that is preferred.Fixes #2851
Test Plan
packages/cli-platform-android/src/commands/runAndroid/__tests__/tryInstallAppOnDevice.test.ts:stagingInternalDebuginstallsapp-stagingInternal-debug.apkfrom metadataacmeStagingDebugstill installsapp-acme-staging-debug.apkwhen metadata is absentyarn test packages/cli-platform-android(5 suites, 21 tests)flavorDimensions 'env'/productFlavors { stagingInternal { dimension 'env' } }, thenrun-android --mode stagingInternalDebug --list-devicesand confirm the APK inandroid/app/build/outputs/apk/stagingInternal/debug/is installed. The same command without--list-devicesalready worked (Gradleinstall).Checklist
react-nativecheckout. Filename selection is covered by the unit tests above; a linked checkout would only re-check the same install path against a real Gradle output.