Skip to content

Commit 5944f07

Browse files
authored
feat: retry installing android app when insufficient storage (#324)
* feat: retry installing android app when insufficient storage * changeset * use stdout; take appId into account
1 parent 3428485 commit 5944f07

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

.changeset/cyan-actors-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@rnef/platform-android': patch
3+
---
4+
5+
feat: retry installing android app when insufficient storage

packages/platform-android/src/lib/commands/runAndroid/tryInstallAppOnDevice.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,30 @@ export async function tryInstallAppOnDevice(
6464
`Installed the app on ${device.readableName} (id: ${deviceId}).`
6565
);
6666
} catch (error) {
67-
loader.stop(`Failed to install the app.`, 1);
68-
throw new RnefError(`Failed to install the app on ${device.readableName}`, {
69-
cause: (error as SubprocessError).stderr,
70-
});
67+
const errorMessage = (error as SubprocessError).stdout;
68+
if (errorMessage.includes('INSTALL_FAILED_INSUFFICIENT_STORAGE')) {
69+
try {
70+
loader.message('Trying to install again due to insufficient storage');
71+
const appId = args.appId ?? androidProject.applicationId;
72+
await spawn(adbPath, ['-s', deviceId, 'uninstall', appId]);
73+
await spawn(adbPath, adbArgs);
74+
loader.stop(
75+
`Installed the app on ${device.readableName} (id: ${deviceId}).`
76+
);
77+
return;
78+
} catch (error) {
79+
loader.stop(
80+
`Failed: Uninstalling and installing the app on ${device.readableName} (id: ${deviceId})`,
81+
1
82+
);
83+
const errorMessage = (error as SubprocessError).stdout;
84+
throw new RnefError(errorMessage);
85+
}
86+
}
87+
loader.stop(
88+
`Failed: Installing the app on ${device.readableName} (id: ${deviceId})`,
89+
1
90+
);
91+
throw new RnefError(errorMessage);
7192
}
7293
}

0 commit comments

Comments
 (0)