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

[TIMOB-17182] Improved Android's handling of min, target, and max api le... #5824

Merged
merged 2 commits into from
Jun 19, 2014
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 20 additions & 7 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ function AndroidBuilder() {

this.tiSymbols = {};

this.minSupportedApiLevel = parseInt(version.parseMin(this.packageJson.vendorDependencies['android sdk']));
this.minSupportedApiLevel = parseInt(this.packageJson.minSDKVersion);
this.minTargetApiLevel = parseInt(version.parseMin(this.packageJson.vendorDependencies['android sdk']));
this.maxSupportedApiLevel = parseInt(version.parseMax(this.packageJson.vendorDependencies['android sdk']));

this.deployTypes = {
Expand Down Expand Up @@ -174,14 +175,14 @@ AndroidBuilder.prototype.config = function config(logger, config, cli) {
// make sure we have an Android SDK and some Android targets
if (!Object.keys(androidInfo.targets).filter(function (id) {
var t = androidInfo.targets[id];
return t.type == 'platform' && t['api-level'] >= _t.minSupportedApiLevel;
return t.type == 'platform' && t['api-level'] >= _t.minTargetApiLevel;
}).length) {
if (Object.keys(androidInfo.targets).length) {
logger.error(__('No valid Android SDK targets found.'));
} else {
logger.error(__('No Android SDK targets found.'));
}
logger.error(__('Please download an Android SDK target API level %s or newer from the Android SDK Manager and try again.', _t.minSupportedApiLevel) + '\n');
logger.error(__('Please download an Android SDK target API level %s or newer from the Android SDK Manager and try again.', _t.minTargetApiLevel) + '\n');
process.exit(1);
}
}
Expand Down Expand Up @@ -1073,7 +1074,7 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
logger.warn('<ti:app xmlns:ti="http://ti.appcelerator.org">'.grey);
logger.warn(' <android>'.grey);
logger.warn(' <manifest>'.grey);
logger.warn((' <uses-sdk android:minSdkVersion="' + this.minSupportedApiLevel + '" android:targetSdkVersion="' + this.minSupportedApiLevel + '" android:maxSdkVersion="' + this.maxSupportedApiLevel + '"/>').magenta);
logger.warn((' <uses-sdk android:minSdkVersion="' + this.minSupportedApiLevel + '" android:targetSdkVersion="' + this.minTargetApiLevel + '" android:maxSdkVersion="' + this.maxSupportedApiLevel + '"/>').magenta);
logger.warn(' </manifest>'.grey);
logger.warn(' </android>'.grey);
logger.warn('</ti:app>'.grey);
Expand All @@ -1087,7 +1088,19 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
}

if (this.minSDK < this.minSupportedApiLevel) {
logger.error(__('Minimum Android SDK version must be %s or newer', this.minSupportedApiLevel) + '\n');
logger.error(__('The current minimum Android SDK version is %s', this.minSDK));
logger.error(__('The minimum supported SDK version must be %s or newer', this.minSupportedApiLevel) + '\n');
process.exit(1);
}

if (this.targetSDK && this.targetSDK < this.minTargetApiLevel) {
logger.error(__('The current target SDK version is %s', this.targetSDK));
logger.error(__('The target SDK version must be %s or newer', this.minTargetApiLevel) + '\n');
process.exit(1);
}

if (this.targetSDK && this.targetSDK < this.minSDK) {
logger.error(__('The target SDK is %s and must be greater than or equal to the minimum supported SDK %s', this.targetSDK, this.minSDK) + '\n');
process.exit(1);
}

Expand Down Expand Up @@ -1117,7 +1130,7 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {

var sdks = Object.keys(targetSDKMap).filter(function (ver) {
return ~~ver > this.minSupportedApiLevel;
}.bind(this)).sort();
}.bind(this)).sort().filter(function (s) { return s >= this.minSDK; }, this);

if (sdks.length) {
logger.log(__('To target Android SDK %s, you first must install it using the Android SDK manager.', String(this.targetSDK).cyan) + '\n');
Expand All @@ -1131,7 +1144,7 @@ AndroidBuilder.prototype.validate = function validate(logger, config, cli) {
logger.log('<ti:app xmlns:ti="http://ti.appcelerator.org">'.grey);
logger.log(' <android>'.grey);
logger.log(' <manifest>'.grey);
logger.log((' <uses-sdk android:minSdkVersion="' + sdks[0] + '" android:targetSdkVersion="' + sdks[0] + '" android:maxSdkVersion="' + this.maxSupportedApiLevel + '"/>').magenta);
logger.log((' <uses-sdk android:minSdkVersion="' + this.minSDK + '" android:targetSdkVersion="' + sdks[0] + '" android:maxSdkVersion="' + this.maxSupportedApiLevel + '"/>').magenta);
logger.log(' </manifest>'.grey);
logger.log(' </android>'.grey);
logger.log('</ti:app>'.grey);
Expand Down
6 changes: 5 additions & 1 deletion android/cli/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@
"Malformed <manifest> definition in the <android> section of the tiapp.xml": "Malformed <manifest> definition in the <android> section of the tiapp.xml",
"Malformed custom AndroidManifest.xml file: %s": "Malformed custom AndroidManifest.xml file: %s",
"%s has been deprecated, please specify the target SDK using the %s tag:": "%s has been deprecated, please specify the target SDK using the %s tag:",
"Minimum Android SDK version must be %s or newer": "Minimum Android SDK version must be %s or newer",
"The current minimum Android SDK version is %s": "The current minimum Android SDK version is %s",
"The minimum supported SDK version must be %s or newer": "The minimum supported SDK version must be %s or newer",
"The current target SDK version is %s": "The current target SDK version is %s",
"The target SDK version must be %s or newer": "The target SDK version must be %s or newer",
"The target SDK is %s and must be greater than or equal to the minimum supported SDK %s": "The target SDK is %s and must be greater than or equal to the minimum supported SDK %s",
"Unable to find a suitable installed Android SDK that is >=%s and <=%s": "Unable to find a suitable installed Android SDK that is >=%s and <=%s",
"Target Android SDK %s is not installed": "Target Android SDK %s is not installed",
"To target Android SDK %s, you first must install it using the Android SDK manager.": "To target Android SDK %s, you first must install it using the Android SDK manager.",
Expand Down
1 change: 1 addition & 0 deletions android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Ping Wang <pwang@appcelerator.com>",
"Allen Yeung <ayeung@appcelerator.com>"
],
"minSDKVersion": "10",
"vendorDependencies": {
"android sdk": ">=14 <=19",
"android build tools": ">=17 <19.x",
Expand Down
2 changes: 1 addition & 1 deletion mobileweb/cli/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@
"Microsoft (R) Windows Phone SDK": "Microsoft (R) Windows Phone SDK",
"Windows Phone v%s Devices & Emulators": "Windows Phone v%s Devices & Emulators",
"ID": "ID",
"Windows Phone Devices & Emulators": "Windows Phone Devices & Emulators",
"None": "None",
"Windows Phone Devices & Emulators": "Windows Phone Devices & Emulators",
"Windows PowerShell": "Windows PowerShell",
"Enabled": "Enabled",
"yes": "yes",
Expand Down