Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android): handle INSTALL_FAILED_OLDER_SDK adb error #92

Merged
merged 1 commit into from
Dec 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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