Skip to content

Commit

Permalink
feat(android): handle INSTALL_FAILED_OLDER_SDK adb error (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
SchnWalter authored and imhoffd committed Dec 2, 2019
1 parent 6bb6585 commit 6616f37
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/android/utils/adb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as path from 'path';
import * as split2 from 'split2';
import * as through2 from 'through2';

import { ADBException, ERR_INCOMPATIBLE_UPDATE, ERR_VERSION_DOWNGRADE } from '../../errors';
import { ADBException, ERR_INCOMPATIBLE_UPDATE, ERR_MIN_SDK_VERSION, ERR_VERSION_DOWNGRADE } from '../../errors';
import { execFile } from '../../utils/process';

import { SDK, getSDKPackage, supplementProcessEnv } from './sdk';
Expand Down Expand Up @@ -193,6 +193,8 @@ export async function installApk(sdk: SDK, device: Device, apk: string): Promise
reject(new ADBException(`Encountered adb error: ${ADBEvent[event]}.`, ERR_INCOMPATIBLE_UPDATE));
} else if (event === ADBEvent.NewerVersionOnDeviceFailure) {
reject(new ADBException(`Encountered adb error: ${ADBEvent[event]}.`, ERR_VERSION_DOWNGRADE));
} else if (event === ADBEvent.NewerSdkRequiredOnDeviceFailure) {
reject(new ADBException(`Encountered adb error: ${ADBEvent[event]}.`, ERR_MIN_SDK_VERSION));
}

cb();
Expand Down Expand Up @@ -223,6 +225,7 @@ export async function uninstallApp(sdk: SDK, device: Device, app: string): Promi
export enum ADBEvent {
IncompatibleUpdateFailure, // signatures do not match the previously installed version
NewerVersionOnDeviceFailure, // version of app on device is newer than the one being deployed
NewerSdkRequiredOnDeviceFailure, // device does not meet minSdkVersion requirement
}

export function parseAdbInstallOutput(line: string): ADBEvent | undefined {
Expand All @@ -233,6 +236,8 @@ export function parseAdbInstallOutput(line: string): ADBEvent | undefined {
event = ADBEvent.IncompatibleUpdateFailure;
} else if (line.includes('INSTALL_FAILED_VERSION_DOWNGRADE')) {
event = ADBEvent.NewerVersionOnDeviceFailure;
} else if (line.includes('INSTALL_FAILED_OLDER_SDK')) {
event = ADBEvent.NewerSdkRequiredOnDeviceFailure;
}

if (typeof event !== 'undefined') {
Expand Down
2 changes: 2 additions & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const ERR_AVD_HOME_NOT_FOUND = 'ERR_AVD_HOME_NOT_FOUND';
export const ERR_EMULATOR_HOME_NOT_FOUND = 'ERR_EMULATOR_HOME_NOT_FOUND';
export const ERR_INCOMPATIBLE_UPDATE = 'ERR_INCOMPATIBLE_UPDATE';
export const ERR_VERSION_DOWNGRADE = 'ERR_VERSION_DOWNGRADE';
export const ERR_MIN_SDK_VERSION = 'ERR_MIN_SDK_VERSION';
export const ERR_INVALID_SDK_PACKAGE = 'ERR_INVALID_SDK_PACKAGE';
export const ERR_INVALID_SERIAL = 'ERR_INVALID_SERIAL';
export const ERR_INVALID_SKIN = 'ERR_INVALID_SKIN';
Expand All @@ -54,6 +55,7 @@ export class CLIException extends Exception<CLIExceptionCode> {}
export type ADBExceptionCode = (
typeof ERR_INCOMPATIBLE_UPDATE |
typeof ERR_VERSION_DOWNGRADE |
typeof ERR_MIN_SDK_VERSION |
typeof ERR_NON_ZERO_EXIT
);

Expand Down

0 comments on commit 6616f37

Please sign in to comment.