From 0fdd5431bb68df4d8eabe3b3177747b16fb811e7 Mon Sep 17 00:00:00 2001 From: Schneider Werner Walter Date: Thu, 28 Nov 2019 23:27:36 +0200 Subject: [PATCH] feat(android): handle INSTALL_FAILED_OLDER_SDK adb error --- src/android/utils/adb.ts | 7 ++++++- src/errors.ts | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/android/utils/adb.ts b/src/android/utils/adb.ts index 0c78c18..38485fe 100644 --- a/src/android/utils/adb.ts +++ b/src/android/utils/adb.ts @@ -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'; @@ -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(); @@ -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 { @@ -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') { diff --git a/src/errors.ts b/src/errors.ts index 86e4047..63f965f 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -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'; @@ -54,6 +55,7 @@ export class CLIException extends Exception {} export type ADBExceptionCode = ( typeof ERR_INCOMPATIBLE_UPDATE | typeof ERR_VERSION_DOWNGRADE | + typeof ERR_MIN_SDK_VERSION | typeof ERR_NON_ZERO_EXIT );