Skip to content

feat: Allow version downgrade on install for React Native apps in RNGP - #59796

Closed
retyui wants to merge 1 commit into
react:mainfrom
retyui:rngp-install-options-downgrade
Closed

retyui wants to merge 1 commit into
react:mainfrom
retyui:rngp-install-options-downgrade

Conversation

@retyui

@retyui retyui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Summary:

Issue:

yarn android --active-arch-only --port 8081
# ^^^ fails with `INSTALL_FAILED_VERSION_DOWNGRADE` if the installed app has a newer version

yarn android --active-arch-only --port 8081 --device emulator-5554
# but if you add `--device` param 💥 NO ERROR at all

Important

Using a --device param force using a CLI (that has -d for adb install ... cmd), see: https://github.com/react-native-community/cli/blob/f4c4ef37ccf98e0205d4a8bc5d9f40f24f1120fd/packages/cli-platform-android/src/commands/runAndroid/tryInstallAppOnDevice.ts#L52
Without--device the app:installDebug task will be used to install an app on all connected devices (no CLI)

Changelog:

[ANDROID] [CHANGED] - Allow version code downgrade during run-android

Test Plan:

// 1. New App
npx @react-native-community/cli init --pm yarn --version 0.88.0-rc.6  RN88downgrade
cd RN88downgrade
// 2. Edit `android/app/build.gradle`
// android {
//  defaultConfig {
//        versionCode 999 // <-bump it
//        versionName "9.9.9"

// 3. Run
yarn android --active-arch-only --port 8081
// No error

// 4. Edit one more time `android/app/build.gradle`
//        versionCode 888 // <-lower it
//        versionName "8.8.8"

// 5. Ran again
yarn android --active-arch-only --port 8081
// Error: `INSTALL_FAILED_VERSION_DOWNGRADE`

// 6. Edit one more time `android/app/build.gradle` 
// android {
//    installation {
//        installOptions.add("-d") // <- ADD THIS (like configureInstallOptionsForApp do)
//    }


// 7. Ran again
yarn android --active-arch-only --port 8081
// 💥 NO ERROR!

Add configureInstallOptionsForApp to AgpConfiguratorUtils, which adds the
'-d' adb install option to every module that applies com.android.application.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 4, 2026
@facebook-github-tools facebook-github-tools Bot added p: Callstack Partner: Callstack Partner labels Nov 4, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 4, 2026

@cortinico cortinico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should merge this. You're adding a -d for ALL the apps just to solve a specific problem.

As mentioned this should either live inside the community CLI or in a patch package.

@retyui

retyui commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

I don't think we should merge this. You're adding a -d for ALL the apps just to solve a specific problem.

As mentioned this should either live inside the community CLI or in a patch package.

I also would like to add apply this in CLI, but without --device argument cli juts simply run a cmd cd android && ./gradlew app:installDebug

@retyui retyui closed this Nov 4, 2026
@retyui
retyui deleted the rngp-install-options-downgrade branch November 4, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Callstack Partner: Callstack Partner Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants