Skip to content

Commit 15c53d7

Browse files
ifsnowthymikee
authored andcommitted
fix: prevent run-android failure when updating APK (#323)
Summary: --------- If we run `react-native run-android` while it's already installed, it will fail with the following error. ```bash info Installing the app on the device (cd android && adb -s emulator-5554 install app/build/outputs/apk/debug/app-x86-debug.apk adb: failed to install app/build/outputs/apk/debug/app-x86-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install me.mycake without first uninstalling.] ``` In the development phase, I think using adb's install options below is much more efficient. ``` -r : Reinstall an existing app, keeping its data. -d : Allow version code downgrade. ``` Test Plan: ---------- Not required.
1 parent 835b1e3 commit 15c53d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/cli/src/commands/runAndroid/runAndroid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ function tryInstallAppOnDevice(args, adbPath, device) {
167167
);
168168

169169
const pathToApk = `${buildDirectory}/${apkFile}`;
170-
const adbArgs = ['-s', device, 'install', pathToApk];
170+
const adbArgs = ['-s', device, 'install', '-rd', pathToApk];
171171
logger.info(
172-
`Installing the app on the device (cd android && adb -s ${device} install ${pathToApk}`,
172+
`Installing the app on the device (cd android && adb -s ${device} install -rd ${pathToApk}`,
173173
);
174174
execFileSync(adbPath, adbArgs, {
175175
stdio: [process.stdin, process.stdout, process.stderr],

0 commit comments

Comments
 (0)