Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sravanmedarapu committed Dec 6, 2016
1 parent 187482a commit ae5cb72
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/tools/android-manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ manifestMethods.targetSdkVersionFromManifest = async function (localApk) {
let args = ['dump', 'badging', localApk];
let {stdout} = await exec(this.binaries.aapt, args);
let targetSdkVersion = new RegExp(/targetSdkVersion:'([^']+)'/g).exec(stdout);
if (!targetSdkVersion) {
throw new Error(`targetSdkVersion is not specified in the application.`);
}
return parseInt(targetSdkVersion[1], 10);
} catch (e) {
log.warn(`Ran into problem getting target SDK; ignoring: ${e.message}`);
return null;
log.errorAndThrow(`fetching targetSdkVersion from local APK failed. Original error: ${e.message}`);
}
};

Expand Down
8 changes: 7 additions & 1 deletion lib/tools/apk-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ apkUtilsMethods.install = async function (apk, replace = true, timeout = 60000)
}
if (apk.includes('.apk')) {
let apiLevel = await this.getApiLevel();
let targetSdk = await this.targetSdkVersionFromManifest(apk);
let targetSdk = null;
try {
targetSdk = await this.targetSdkVersionFromManifest(apk);
} catch (e) {
//avoiding logging error stack, as calling library function would have logged
log.warn(`Ran into problem getting target SDK version; ignoring...`);
}
if (apiLevel >= 23 && (!targetSdk || targetSdk >= 23)) {
await this.grantAllPermissions(await this.getPackageName(apk));
}
Expand Down

0 comments on commit ae5cb72

Please sign in to comment.