Skip to content

Commit

Permalink
[cli] Automaticaly handle INSTALL_FAILED_UPDATE_INCOMPATIBLE when try…
Browse files Browse the repository at this point in the history
…ing to install an app (#187)

* [cli] Automaticaly handle INSTALL_FAILED_UPDATE_INCOMPATIBLE when trying to install an app

* Add changelog entry
  • Loading branch information
gabrieldonadel authored Mar 1, 2024
1 parent c9a1732 commit 672dc72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Add support for launching Expo updates. ([#134](https://github.com/expo/orbit/pull/134), [#137](https://github.com/expo/orbit/pull/137), [#138](https://github.com/expo/orbit/pull/138), [#144](https://github.com/expo/orbit/pull/144), [#148](https://github.com/expo/orbit/pull/148) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Add experimental support for Windows and Linux. ([#152](https://github.com/expo/orbit/pull/152), [#157](https://github.com/expo/orbit/pull/157), [#158](https://github.com/expo/orbit/pull/158), [#160](https://github.com/expo/orbit/pull/160), [#161](https://github.com/expo/orbit/pull/161), [#165](https://github.com/expo/orbit/pull/165), [#170](https://github.com/expo/orbit/pull/170), [#171](https://github.com/expo/orbit/pull/171), [#172](https://github.com/expo/orbit/pull/172), [#173](https://github.com/expo/orbit/pull/173), [#174](https://github.com/expo/orbit/pull/174), [#175](https://github.com/expo/orbit/pull/175), [#177](https://github.com/expo/orbit/pull/177), [#178](https://github.com/expo/orbit/pull/178), [#180](https://github.com/expo/orbit/pull/180), [#181](https://github.com/expo/orbit/pull/181), [#182](https://github.com/expo/orbit/pull/182), [#185](https://github.com/expo/orbit/pull/185) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Migrate Sparkle to Expo Modules. ([#184](https://github.com/expo/orbit/pull/184) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Automatically handle installing incompatible Android app updates. ([#187](https://github.com/expo/orbit/pull/187) by [@gabrieldonadel](https://github.com/gabrieldonadel))

### 🐛 Bug fixes

Expand Down
12 changes: 11 additions & 1 deletion apps/cli/src/commands/InstallAndLaunchApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,17 @@ async function installAndLaunchIOSAppAsync(appPath: string, deviceId: string) {
async function installAndLaunchAndroidAppAsync(appPath: string, deviceId: string) {
const device = await Emulator.getRunningDeviceAsync(deviceId);

await Emulator.installAppAsync(device, appPath);
const { packageName, activityName } = await Emulator.getAptParametersAsync(appPath);
try {
await Emulator.installAppAsync(device, appPath);
} catch (error) {
if (error instanceof Error && error.message.includes('INSTALL_FAILED_UPDATE_INCOMPATIBLE')) {
await Emulator.uninstallAppAsync(device, packageName);
await Emulator.installAppAsync(device, appPath);
} else {
throw error;
}
}

await Emulator.startAppAsync(device, packageName, activityName);
}

0 comments on commit 672dc72

Please sign in to comment.