Skip to content

Pass correct parameters to gradle build #856

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

Merged
merged 1 commit into from
Sep 7, 2015

Conversation

rosen-vladimirov
Copy link
Contributor

Pass correct parameters to gradle build

We should pass correct parameters to android build. We need:

  • Compile SDK - at least 21
  • BuildTools version - at least 22
  • AppCompat lib (Android Support) version - same as compile SDK
  • Target SDK - the selected target by user - there's no need to have it

Add AndroidToolsInfo class that calculates all required and installed versions of required Android tools. This class prints warnings when the public method getToolsInfo is called without parameters and prints errors when the showWarningsAsErrors parameter is set to true. When tns doctor command is called, the checks will print warnings and when tns platform add android or tns build/prepare... android commands are used, the AndroidToolsInfo will break the execution when incorrect Android setup is detected.

Fixes #840

@rosen-vladimirov rosen-vladimirov self-assigned this Sep 2, 2015
@rosen-vladimirov rosen-vladimirov added this to the 1.3.0 milestone Sep 2, 2015
@ns-bot
Copy link

ns-bot commented Sep 2, 2015


<% if(isHtml) { %>
### Attributes
* `<API Level>` is a valid Android API level. For example: 17, 19, MNC.<% if(isHtml) { %> For a complete list of the Android API levels and their corresponding Android versions, click [here](http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#platform).<% } %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would not support MNC, perhaps it is best to avoid mentioning it?

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from 33da0ad to cf3f6f6 Compare September 3, 2015 15:23
@rosen-vladimirov rosen-vladimirov changed the title Save the targetSdk in AndroidManifest.xml Pass correct parameters to gradle build Sep 3, 2015
@ns-bot
Copy link

ns-bot commented Sep 3, 2015

let newTarget = this.$options.sdk ? `${AndroidProjectService.ANDROID_TARGET_PREFIX}-${this.$options.sdk}` : targetFromAndroidManifest ? `${AndroidProjectService.ANDROID_TARGET_PREFIX}-${targetFromAndroidManifest}`: this.getLatestValidAndroidTarget().wait();
this.$logger.trace(`TargetSDK from AndroidManifest is ${targetFromAndroidManifest}. Selected target is: ${newTarget}.`);
if(!_.contains(this.SUPPORTED_TARGETS, newTarget)) {
let versionNumber = parseInt(_.last(newTarget.split("-")));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use parseAndroidSdkString method

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from cf3f6f6 to c428bc0 Compare September 5, 2015 14:00
@ns-bot
Copy link

ns-bot commented Sep 5, 2015

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from c428bc0 to a67862d Compare September 5, 2015 14:06
@ns-bot
Copy link

ns-bot commented Sep 5, 2015

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from a67862d to 6f0d343 Compare September 7, 2015 06:22
@ns-bot
Copy link

ns-bot commented Sep 7, 2015

"use strict";

import path = require("path");
import semver = require("semver");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ES6 Imports can be used here

@rosen-vladimirov
Copy link
Contributor Author

ping @ikoevska for the messages

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from 6f0d343 to 308b3f3 Compare September 7, 2015 07:02
@ns-bot
Copy link

ns-bot commented Sep 7, 2015

@Mitko-Kerezov
Copy link
Contributor

👍

if(additionalMsg) {
this.$logger.info(additionalMsg);
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps

if (this.showWarningsAsErrors) {
    this.$errors.failWithoutHelp(msg);
} else {
    this.$logger.warn(msg);
}

if(additionalMsg) {
    this.$logger.info(additionalMsg);
}

or I am missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are correct :)

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from 308b3f3 to 8e886a5 Compare September 7, 2015 08:09

private getAndroidHome(): string {
let androidHomeEnvVar = process.env["ANDROID_HOME"];
if(!androidHomeEnvVar) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this message be printed twice?

@ns-bot
Copy link

ns-bot commented Sep 7, 2015

/**
* The Android targetSdkVersion specified by the user.
* In case it is not specified, compileSdkVersion will be used for targetSdkVersion.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are totally awesome!

let minSupportedVersion = this.parseAndroidSdkString(_.first(supportedVersions));
let maxSupportedVersion = this.parseAndroidSdkString(_.last(supportedVersions));
if(targetSdk && (targetSdk < minSupportedVersion)) {
this.printMessage(`The selected target SDK ${newTarget} is not supported. You should target at least ${minSupportedVersion}.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be errors.failWithoutHelp?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In one case yes - in other - not :D
Check the description of the PR

@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from 8e886a5 to 671802d Compare September 7, 2015 11:07
@ns-bot
Copy link

ns-bot commented Sep 7, 2015

private $logger: ILogger,
private $options: IOptions) {}

public getToolsInfo(options?: {showWarningsAsErrors: boolean}): IFuture<IAndroidToolsInfoData> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need of showWarningsAsErrors, I'll remove it

@teobugslayer
Copy link
Contributor

👍 for the code

if(targetSdk && (targetSdk < minSupportedVersion)) {
this.printMessage(`The selected target SDK ${newTarget} is not supported. You should target at least ${minSupportedVersion}.`);
} else if(!targetSdk || targetSdk > this.getMaxSupportedVersion()) {
this.$logger.warn(`The selected Android target '${newTarget}' is not verified as supported. Some functionality may not work as expected.`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support for the selected Android target SDK ${newTarget} is not verified. Your Android app might not work as expected.

We should pass correct parameters to android build. We need:
* Compile SDK - at least 21
* BuildTools version - at least 22
* AppCompat lib (Android Support) version - same as compile SDK
* Target SDK - the selected target by user - there's no need to have it

Add AndroidToolsInfo class that calculates all required and installed versions of required Android tools. This class prints warnings when the public method getToolsInfo is called without parameters and prints errors when the showWarningsAsErrors parameter is set to true. When `tns doctor` command is called, the checks will print warnings and when `tns platform add android` or `tns build/prepare... android` commands are used, the AndroidToolsInfo will break the execution when incorrect Android setup is detected.

Fixes #840
@rosen-vladimirov rosen-vladimirov force-pushed the vladimirov/fix-android-sdk-param branch from 671802d to 23bdee0 Compare September 7, 2015 11:50
@ns-bot
Copy link

ns-bot commented Sep 7, 2015

rosen-vladimirov added a commit that referenced this pull request Sep 7, 2015
…param

Pass correct parameters to gradle build
@rosen-vladimirov rosen-vladimirov merged commit f7b0c13 into master Sep 7, 2015
@rosen-vladimirov rosen-vladimirov deleted the vladimirov/fix-android-sdk-param branch September 7, 2015 11:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants