Skip to content

Conversation

Plamen5kov
Copy link
Contributor

@Plamen5kov Plamen5kov commented Feb 13, 2018

With the update of the android plugin for gradle to 3.0.1 there's a breaking change in the folder structure where the CLI searches for the application file:

old search path: <project_name>/platforms/android/app/build/outputs/apk/
new search path: <project_name>/platforms/android/app/build/outputs/apk/debug/

Another change will also be introduced in the tns-android@4.0.0 project template which will stop renaming the final application file:

old default name: <project-name>-<build-version>[-abi].apk
new default name: app-<build-version>.apk

This PR handles both scenarios and is backward compatible.

related issue: NativeScript/android#950

@Plamen5kov Plamen5kov self-assigned this Feb 13, 2018
@Plamen5kov Plamen5kov added this to the 4.0.0 milestone Feb 13, 2018
@Plamen5kov Plamen5kov force-pushed the plamen5kov/update-find-apk-logic branch from 456c2dd to 4a9c49d Compare February 14, 2018 06:53
@@ -104,6 +105,24 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
return this._platformData;
}

private getDeviceBuildOutputPath(currentPath: string, projectData: IProjectData): string {
const currentPlatformData: IDictionary<any> = this.$projectDataService.getNSValue(projectData.projectDir, constants.TNS_ANDROID_RUNTIME_NAME),
platformVersion = currentPlatformData && currentPlatformData[constants.VERSION_STRING],
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer each const be on a separate line here - this way each variable declaration is a separate statement and debugging is easier and overall it seams neater to me

if (semver.valid(platformVersion)) {
const gradleAndroidPluginVersion3xx = "4.0.0";
const normalizedPlatformVersion = `${semver.major(platformVersion)}.${semver.minor(platformVersion)}.0`;
if (semver.gte(normalizedPlatformVersion, gradleAndroidPluginVersion3xx)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this logic can be simplified to

if (semver.lt(normalizedPlatformVersion, gradleAndroidPluginVersion3xx)) {
    return currentPath;
}

by inverting the logic you can skip the second return statement and just reuse the one on line 123

Copy link
Contributor

@Mitko-Kerezov Mitko-Kerezov left a comment

Choose a reason for hiding this comment

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

Looks all right to me, splendid work!

@Plamen5kov Plamen5kov merged commit bcd794e into master Feb 14, 2018
@Plamen5kov Plamen5kov deleted the plamen5kov/update-find-apk-logic branch February 14, 2018 12:58
Plamen5kov added a commit that referenced this pull request Feb 21, 2018
…-logic

refactor: add logic for finding apk name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants