Skip to content

Commit

Permalink
Merge pull request #6234 from cb1kenobi/timob-17874_3_4_X
Browse files Browse the repository at this point in the history
[TIMOB-17874] Properly convert all Android SDK versions from codenames t...
  • Loading branch information
skypanther committed Oct 31, 2014
2 parents 688aff4 + a1457b5 commit 78cf47a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
28 changes: 21 additions & 7 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,7 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
}, this);

try {
this.tiappAndroidManifest = cli.tiapp.android && cli.tiapp.android.manifest && (new AndroidManifest).parse(cli.tiapp.android.manifest);
var tiappAndroidManifest = this.tiappAndroidManifest = cli.tiapp.android && cli.tiapp.android.manifest && (new AndroidManifest).parse(cli.tiapp.android.manifest);
} catch (ex) {
logger.error(__('Malformed <manifest> definition in the <android> section of the tiapp.xml') + '\n');
process.exit(1);
Expand All @@ -1068,7 +1068,7 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
}

// validate the sdk levels
var usesSDK = (this.tiappAndroidManifest && this.tiappAndroidManifest['uses-sdk']) || (this.customAndroidManifest && this.customAndroidManifest['uses-sdk']);
var usesSDK = (tiappAndroidManifest && tiappAndroidManifest['uses-sdk']) || (this.customAndroidManifest && this.customAndroidManifest['uses-sdk']);

this.minSDK = this.minSupportedApiLevel;
this.targetSDK = cli.tiapp.android && ~~cli.tiapp.android['tool-api-level'] || null;
Expand All @@ -1088,12 +1088,26 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
logger.log();
}

function normalizeVersion(ver, type) {
ver = (ver && targetSDKMap[ver] && targetSDKMap[ver].sdk) || ver;
if (ver && tiappAndroidManifest) {
tiappAndroidManifest['uses-sdk'] || (tiappAndroidManifest['uses-sdk'] = {});
tiappAndroidManifest['uses-sdk'][type] = ver;
}
return ver;
}

if (usesSDK) {
usesSDK['minSdkVersion'] && (this.minSDK = usesSDK['minSdkVersion']);
usesSDK['targetSdkVersion'] && (this.targetSDK = usesSDK['targetSdkVersion']);
usesSDK['maxSdkVersion'] && (this.maxSDK = usesSDK['maxSdkVersion']);
usesSDK.minSdkVersion && (this.minSDK = usesSDK.minSdkVersion);
usesSDK.targetSdkVersion && (this.targetSDK = usesSDK.targetSdkVersion);
usesSDK.maxSdkVersion && (this.maxSDK = usesSDK.maxSdkVersion);
}

// make sure the SDK versions are actual SDK versions and not the codenames
this.minSDK = normalizeVersion(this.minSDK, 'minSdkVersion');
this.targetSDK = normalizeVersion(this.targetSDK, 'targetSdkVersion');
this.maxSDK = normalizeVersion(this.maxSDK, 'maxSdkVersion');

// min sdk is too old
var minApiLevel = targetSDKMap[this.minSDK] && targetSDKMap[this.minSDK].sdk;
if (minApiLevel && minApiLevel < this.minSupportedApiLevel) {
Expand Down Expand Up @@ -1154,9 +1168,9 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
// if no target sdk, then default to most recent supported/installed
if (!this.targetSDK) {
var levels = Object.keys(targetSDKMap).sort(function (a, b) {
if (a.sdk === b.sdk && a.revision === b.revision) {
if (targetSDKMap[a].sdk === targetSDKMap[b].sdk && targetSDKMap[a].revision === targetSDKMap[b].revision) {
return 0;
} else if (a.sdk < b.sdk || (a.sdk === b.sdk && a.revision < b.revision)) {
} else if (targetSDKMap[a].sdk < targetSDKMap[b].sdk || (targetSDKMap[a].sdk === targetSDKMap[b].sdk && targetSDKMap[a].revision < targetSDKMap[b].revision)) {
return -1;
}
return 1;
Expand Down
6 changes: 3 additions & 3 deletions android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
],
"minSDKVersion": "10",
"vendorDependencies": {
"android sdk": ">=14 <=20",
"android build tools": ">=17 <20.x",
"android platform tools": ">=17 <=20.x",
"android sdk": ">=14 <=21",
"android build tools": ">=17 <21.x",
"android platform tools": ">=17 <=21.x",
"android tools": "<=23.x",
"android ndk": ">=r8e <=r9",
"node": ">0.8.0 <=0.10.x",
Expand Down
2 changes: 1 addition & 1 deletion node_modules/titanium-sdk/lib/adb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 78cf47a

Please sign in to comment.