Skip to content

Commit a95caa5

Browse files
KristianDDrosen-vladimirov
authored andcommitted
fix: build projects with SDK28 if runtime below 6.1.0
1 parent 79edd94 commit a95caa5

8 files changed

+28
-22
lines changed

lib/android-tools-info.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
1010
}
1111

1212
@cache()
13-
public getToolsInfo(): IAndroidToolsInfoData {
14-
const infoData: IAndroidToolsInfoData = <IAndroidToolsInfoData>(androidToolsInfo.getToolsInfo());
13+
public getToolsInfo(config: IProjectDir): IAndroidToolsInfoData {
14+
const infoData: IAndroidToolsInfoData = <IAndroidToolsInfoData>(androidToolsInfo.getToolsInfo({projectDir: config.projectDir}));
1515

1616
infoData.androidHomeEnvVar = androidToolsInfo.androidHome;
1717
infoData.compileSdkVersion = this.getCompileSdkVersion(infoData.installedTargets, infoData.compileSdkVersion);
@@ -29,7 +29,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
2929
const showWarningsAsErrors = options && options.showWarningsAsErrors;
3030
const isAndroidHomeValid = this.validateAndroidHomeEnvVariable(options);
3131

32-
detectedErrors = androidToolsInfo.validateInfo().map(warning => this.printMessage(warning.warning, showWarningsAsErrors)).length > 0;
32+
detectedErrors = androidToolsInfo.validateInfo({projectDir: options.projectDir}).map(warning => this.printMessage(warning.warning, showWarningsAsErrors)).length > 0;
3333

3434
if (options && options.validateTargetSdk) {
3535
detectedErrors = this.validateTargetSdk(options);
@@ -38,17 +38,16 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
3838
return detectedErrors || !isAndroidHomeValid;
3939
}
4040

41-
public validateTargetSdk(options?: IAndroidToolsInfoOptions): boolean {
41+
public validateTargetSdk(options: IAndroidToolsInfoOptions): boolean {
4242
let detectedErrors = false;
43-
const showWarningsAsErrors = options && options.showWarningsAsErrors;
4443

45-
const toolsInfoData = this.getToolsInfo();
44+
const toolsInfoData = this.getToolsInfo({ projectDir: options.projectDir});
4645
const targetSdk = toolsInfoData.targetSdkVersion;
4746

48-
detectedErrors = androidToolsInfo.validateMinSupportedTargetSdk(targetSdk).map(warning => this.printMessage(warning.warning, showWarningsAsErrors)).length > 0;
47+
detectedErrors = androidToolsInfo.validateMinSupportedTargetSdk({targetSdk, projectDir: options.projectDir}).map(warning => this.printMessage(warning.warning, options.showWarningsAsErrors)).length > 0;
4948

5049
if (!detectedErrors) {
51-
androidToolsInfo.validataMaxSupportedTargetSdk(targetSdk).map(warning => this.$logger.warn(warning.warning));
50+
androidToolsInfo.validataMaxSupportedTargetSdk({targetSdk, projectDir: options.projectDir}).map(warning => this.$logger.warn(warning.warning));
5251
}
5352

5453
return detectedErrors;

lib/declarations.d.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,10 @@ interface IAndroidToolsInfo {
646646
/**
647647
* Provides information about installed Android SDKs, Build Tools, Support Library
648648
* and ANDROID_HOME environement variable.
649+
* @param {IProjectDir} config Object with a single property - projectDir. This is the root directory where NativeScript project is located.
649650
* @return {IAndroidToolsInfoData} Information about installed Android Tools and SDKs.
650651
*/
651-
getToolsInfo(): IAndroidToolsInfoData;
652+
getToolsInfo(config?: IProjectDir): IAndroidToolsInfoData;
652653

653654
/**
654655
* Validates the information about required Android tools and SDK versions.
@@ -720,11 +721,11 @@ interface IAndroidToolsInfoData extends NativeScriptDoctor.IAndroidToolsInfoData
720721
/**
721722
* Describes options that can be passed to methods from IAndroidToolsInfo interface
722723
*/
723-
interface IAndroidToolsInfoOptions {
724+
interface IAndroidToolsInfoOptions extends Partial<IProjectDir> {
724725
/**
725726
* Defines if the warning messages should treated as error.
726727
*/
727-
showWarningsAsErrors: boolean;
728+
showWarningsAsErrors?: boolean;
728729
}
729730

730731
interface IAndroidToolsInfoValidateInput extends IAndroidToolsInfoOptions {

lib/definitions/android-plugin-migrator.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface IAndroidPluginBuildService {
1919
* Describes data required for building plugin for Android.
2020
* The data can be consumed in the buildAndroidPlugin hook.
2121
*/
22-
interface IBuildAndroidPluginData {
22+
interface IBuildAndroidPluginData extends Partial<IProjectDir> {
2323
/**
2424
* Directory where the plugin will be build.
2525
* Usually this is the `<project dir>/platforms/tempPlugin/<plugin name>` dir.

lib/services/android-plugin-build-service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
189189
await this.updateManifest(manifestFilePath, pluginTempMainSrcDir, shortPluginName);
190190
this.copySourceSetDirectories(androidSourceDirectories, pluginTempMainSrcDir);
191191
await this.setupGradle(pluginTempDir, options.platformsAndroidDirPath, options.projectDir);
192-
await this.buildPlugin({ pluginDir: pluginTempDir, pluginName: options.pluginName });
192+
await this.buildPlugin({ pluginDir: pluginTempDir, pluginName: options.pluginName, projectDir: options.projectDir });
193193
this.$watchIgnoreListService.addFileToIgnoreList(path.join(options.aarOutputDir, `${shortPluginName}.aar`));
194194
this.copyAar(shortPluginName, pluginTempDir, options.aarOutputDir);
195195
this.writePluginHashInfo(pluginSourceFileHashesInfo, pluginTempDir);
@@ -440,8 +440,8 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
440440
@hook("buildAndroidPlugin")
441441
private async buildPlugin(pluginBuildSettings: IBuildAndroidPluginData): Promise<void> {
442442
if (!pluginBuildSettings.androidToolsInfo) {
443-
this.$androidToolsInfo.validateInfo({ showWarningsAsErrors: true, validateTargetSdk: true });
444-
pluginBuildSettings.androidToolsInfo = this.$androidToolsInfo.getToolsInfo();
443+
this.$androidToolsInfo.validateInfo({ showWarningsAsErrors: true, validateTargetSdk: true, projectDir: pluginBuildSettings.projectDir });
444+
pluginBuildSettings.androidToolsInfo = this.$androidToolsInfo.getToolsInfo({ projectDir: pluginBuildSettings.projectDir });
445445
}
446446

447447
const gradlew = this.$hostInfo.isWindows ? "gradlew.bat" : "./gradlew";

lib/services/android-project-service.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
122122
notConfiguredEnvOptions
123123
});
124124

125-
this.$androidToolsInfo.validateTargetSdk({ showWarningsAsErrors: true });
125+
this.$androidToolsInfo.validateTargetSdk({ showWarningsAsErrors: true, projectDir: projectData.projectDir });
126126

127127
return {
128128
checkEnvironmentRequirementsOutput
@@ -135,7 +135,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
135135
}
136136

137137
this.$fs.ensureDirectoryExists(this.getPlatformData(projectData).projectRoot);
138-
const androidToolsInfo = this.$androidToolsInfo.getToolsInfo();
138+
const androidToolsInfo = this.$androidToolsInfo.getToolsInfo({ projectDir: projectData.projectDir});
139139
const targetSdkVersion = androidToolsInfo && androidToolsInfo.targetSdkVersion;
140140
this.$logger.trace(`Using Android SDK '${targetSdkVersion}'.`);
141141

lib/services/android/gradle-build-args-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class GradleBuildArgsService implements IGradleBuildArgsService {
2222
private getBaseTaskArgs(buildData: IAndroidBuildData): string[] {
2323
const args = this.getBuildLoggingArgs();
2424

25-
const toolsInfo = this.$androidToolsInfo.getToolsInfo();
25+
const toolsInfo = this.$androidToolsInfo.getToolsInfo({projectDir: buildData.projectDir});
2626
args.push(
2727
`-PcompileSdk=android-${toolsInfo.compileSdkVersion}`,
2828
`-PtargetSdk=${toolsInfo.targetSdkVersion}`,

npm-shrinkwrap.json

+9-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"mkdirp": "0.5.1",
6060
"mute-stream": "0.0.5",
6161
"nativescript-dev-xcode": "0.2.0",
62-
"nativescript-doctor": "1.11.0-rc.0",
62+
"nativescript-doctor": "1.11.0-rc.1",
6363
"nativescript-preview-sdk": "0.3.4",
6464
"open": "0.0.5",
6565
"ora": "2.0.0",

0 commit comments

Comments
 (0)