Skip to content

Commit

Permalink
feat(android): handle adb error re: improper signing
Browse files Browse the repository at this point in the history
  • Loading branch information
imhoffd committed Apr 2, 2020
1 parent bd4c5f6 commit 829585f
Show file tree
Hide file tree
Showing 2 changed files with 7 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_MIN_SDK_VERSION, ERR_VERSION_DOWNGRADE } from '../../errors';
import { ADBException, ERR_INCOMPATIBLE_UPDATE, ERR_MIN_SDK_VERSION, ERR_NO_CERTIFICATES, ERR_VERSION_DOWNGRADE } from '../../errors';
import { execFile } from '../../utils/process';

import { SDK, getSDKPackage, supplementProcessEnv } from './sdk';
Expand Down Expand Up @@ -195,6 +195,8 @@ export async function installApk(sdk: SDK, device: Device, apk: string): Promise
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));
} else if (event === ADBEvent.NoCertificates) {
reject(new ADBException(`Encountered adb error: ${ADBEvent[event]}.`, ERR_NO_CERTIFICATES));
}

cb();
Expand Down Expand Up @@ -226,6 +228,7 @@ 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
NoCertificates, // no certificates in APK, likely due to improper signing config
}

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

if (typeof event !== 'undefined') {
Expand Down
1 change: 1 addition & 0 deletions src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ 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_NO_CERTIFICATES = 'ERR_NO_CERTIFICATES';
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 Down

0 comments on commit 829585f

Please sign in to comment.