Skip to content

feat: Allow version code downgrade during run-android - #257

Closed
retyui wants to merge 1 commit into
react-native-community:mainfrom
retyui:feat/retyui/apk-downgrade
Closed

retyui wants to merge 1 commit into
react-native-community:mainfrom
retyui:feat/retyui/apk-downgrade

Conversation

@retyui

@retyui retyui commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

Super annoying 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

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

Changelog:

[ANDROID] [ADDED] - 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
//    }


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

@retyui

retyui commented Oct 15, 2026

Copy link
Copy Markdown
Contributor Author

@cortinico Could you please review this pr

@retyui
retyui force-pushed the feat/retyui/apk-downgrade branch from 95a7f64 to f76d6f6 Compare November 3, 2026 09:14
@retyui

retyui commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

@cortinico Do you need anything else from my side to move forward with this PR?

@cortinico

Copy link
Copy Markdown
Member

This change should not go inside the template. Instead it should be added in the run-android command inside the React Native Community CLI here https://github.com/react-native-community/cli

@cortinico cortinico closed this Nov 3, 2026
@retyui

retyui commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Unfortunately no CLI code is used during run-android (for all devices) (for single device run the CLI have a fix already)

So, I created this PR: react/react-native#59796

@retyui
retyui deleted the feat/retyui/apk-downgrade branch November 4, 2026 11:34
@cortinico

Copy link
Copy Markdown
Member

Unfortunately no CLI code is used during run-android (for all devices) (for single device run the CLI have a fix already)

Oh so the problem is for all devices only?

@retyui

retyui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Unfortunately no CLI code is used during run-android (for all devices) (for single device run the CLI have a fix already)

Oh so the problem is for all devices only?

"all devices" - meant to run the run-android cmd without --device arg.
So only ./gradlew app:installDebug will be exec

I didn't know how to pass a -d argument thought that cmd

but I hope this will help: react-native-community/cli#2882

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants