From 2f287ae3da225379463b6d6753caff4e70d8c4ce Mon Sep 17 00:00:00 2001 From: rosen-vladimirov Date: Tue, 30 Aug 2016 09:31:11 +0300 Subject: [PATCH] Fix failing android build command by forcing use of gradle When there's `platforms/android` directory, but in package.json there's no entry in `nativescript` for android platform, calling `tns build android` or any build related command will fail with error: `Cannot read property 'version' of undefined` The reason is that we are trying to check the version in package.json and check if it allows us to use gradle (previously Android builds required Ant). Prevent the error and force using gradle in such case. --- lib/services/android-project-service.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index cbd50190f9..f77d221ce1 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -445,10 +445,11 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject if (!this._canUseGradle) { if (!frameworkVersion) { this.$projectDataService.initialize(this.$projectData.projectDir); - frameworkVersion = this.$projectDataService.getValue(this.platformData.frameworkPackageName).wait().version; + let frameworkInfoInProjectFile = this.$projectDataService.getValue(this.platformData.frameworkPackageName).wait(); + frameworkVersion = frameworkInfoInProjectFile && frameworkInfoInProjectFile.version; } - this._canUseGradle = semver.gte(frameworkVersion, AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE); + this._canUseGradle = !frameworkVersion || semver.gte(frameworkVersion, AndroidProjectService.MIN_RUNTIME_VERSION_WITH_GRADLE); } return this._canUseGradle;