Skip to content

Commit 4a9c49d

Browse files
committed
refactor: add logic for finding apk name
1 parent 853eff6 commit 4a9c49d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

lib/services/android-project-service.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,15 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
8282
platformProjectService: this,
8383
emulatorServices: this.$androidEmulatorServices,
8484
projectRoot: projectRoot,
85-
deviceBuildOutputPath: path.join(...deviceBuildOutputArr),
85+
deviceBuildOutputPath: this.getDeviceBuildOutputPath(path.join(...deviceBuildOutputArr), projectData),
8686
getValidPackageNames: (buildOptions: { isReleaseBuild?: boolean, isForDevice?: boolean }): string[] => {
8787
const buildMode = buildOptions.isReleaseBuild ? Configurations.Release.toLowerCase() : Configurations.Debug.toLowerCase();
8888

8989
return [
9090
`${packageName}-${buildMode}.apk`,
9191
`${projectData.projectName}-${buildMode}.apk`,
92-
`${projectData.projectName}.apk`
92+
`${projectData.projectName}.apk`,
93+
`app-${buildMode}.apk`
9394
];
9495
},
9596
frameworkFilesExtensions: [".jar", ".dat", ".so"],
@@ -104,6 +105,25 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
104105
return this._platformData;
105106
}
106107

108+
private getDeviceBuildOutputPath(currentPath: string, projectData: IProjectData): string {
109+
const currentPlatformData: IDictionary<any> = this.$projectDataService.getNSValue(projectData.projectDir, constants.TNS_ANDROID_RUNTIME_NAME);
110+
const platformVersion = currentPlatformData && currentPlatformData[constants.VERSION_STRING];
111+
112+
if (!platformVersion ||
113+
platformVersion === constants.PackageVersion.NEXT ||
114+
platformVersion === constants.PackageVersion.LATEST) {
115+
return currentPath;
116+
}
117+
118+
const gradleAndroidPluginVersion3xx = "4.0.0";
119+
const normalizedPlatformVersion = `${semver.major(platformVersion)}.${semver.minor(platformVersion)}.0`;
120+
121+
if (semver.gte(normalizedPlatformVersion, gradleAndroidPluginVersion3xx)) {
122+
return path.join(currentPath, "debug");
123+
}
124+
return currentPath;
125+
}
126+
107127
// TODO: Remove prior to the 4.0 CLI release @Pip3r4o @PanayotCankov
108128
// Similar to the private method of the same name in platform-service.
109129
private getCurrentPlatformVersion(platformData: IPlatformData, projectData: IProjectData): string {

0 commit comments

Comments
 (0)