Skip to content

Navigation Menu

Sign in
Sign up

fix(android): install camelCase flavor APKs from output-metadata.json - #2853

Open
cpruijsen wants to merge 1 commit into
react-native-community:main from
cpruijsen:fix/issue-2851
Open

fix(android): install camelCase flavor APKs from output-metadata.json #2853
cpruijsen wants to merge 1 commit into
react-native-community:main from
cpruijsen:fix/issue-2851

Conversation

@cpruijsen

@cpruijsen cpruijsen commented Sep 11, 2026

Copy link
Copy Markdown

Summary

run-android --device / --list-devices / --interactive installs the outputFile named in AGP output-metadata.json instead of guessing a hyphenated filename from --mode. Gradle writes app-stagingInternal-debug.apk for a camelCase product flavor (for example stagingInternalDebug); the CLI looked for app-staging-internal-debug.apk because it derived the filename by splitting --mode on 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: acmeStagingDebug is either one flavor named acmeStaging or the flavors acme and staging, and those produce different filenames in the same directory. #2324 / #2762 already fixed the directory; the CLI still guessed the filename.

output-metadata.json is 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.json first, 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 --mode alone; the reporter already verified the metadata approach on 20.2.0 with --list-devices and --device. Can switch to the dual-candidate heuristic if that is preferred.

Fixes #2851

Test Plan

  • Unit tests in packages/cli-platform-android/src/commands/runAndroid/__tests__/tryInstallAppOnDevice.test.ts:
    • camelCase flavor stagingInternalDebug installs app-stagingInternal-debug.apk from metadata
    • ABI splits follow device CPU preference, not metadata order
    • multi-dimension acmeStagingDebug still installs app-acme-staging-debug.apk when metadata is absent
    • still errors when no APK is present
  • yarn test packages/cli-platform-android (5 suites, 21 tests)
  • Optional, needs a device/emulator and a flavored app: add flavorDimensions 'env' / productFlavors { stagingInternal { dimension 'env' } }, then run-android --mode stagingInternalDebug --list-devices and confirm the APK in android/app/build/outputs/apk/stagingInternal/debug/ is installed. The same command without --list-devices already worked (Gradle install).

Checklist

  • Documentation is up to date.
  • Follows commit message convention described in CONTRIBUTING.md.
  • For functional changes, my test plan has linked these CLI changes into a local react-native checkout. 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.

Splitting --mode on capitals cannot distinguish a single camelCase flavor
from multiple flavor dimensions, so prefer the filename AGP already wrote.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cortinico cortinico Awaiting requested review from cortinico cortinico is a code owner

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

run-android: "Could not find the correct install APK file" for single-dimension camelCase product flavors when targeting a specific device

1 participant

AltStyle によって変換されたページ (->オリジナル) /