Skip to content

Commit 0f8e88e

Browse files
committed
chore: remove the support for android < 3.4.0
1 parent 599eb02 commit 0f8e88e

File tree

1 file changed

+6
-73
lines changed

1 file changed

+6
-73
lines changed

lib/services/android-project-service.ts

Lines changed: 6 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
1313
private static ANDROID_PLATFORM_NAME = "android";
1414
private static MIN_RUNTIME_VERSION_WITH_GRADLE = "1.5.0";
1515

16-
private isAndroidStudioTemplate: boolean;
17-
1816
constructor(private $androidToolsInfo: IAndroidToolsInfo,
1917
private $errors: IErrors,
2018
$fs: IFileSystem,
@@ -29,7 +27,6 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
2927
private $gradleCommandService: IGradleCommandService,
3028
private $gradleBuildService: IGradleBuildService) {
3129
super($fs, $projectDataService);
32-
this.isAndroidStudioTemplate = false;
3330
}
3431

3532
private _platformData: IPlatformData = null;
@@ -39,27 +36,10 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
3936
}
4037
if (projectData && projectData.platformsDir) {
4138
const projectRoot = path.join(projectData.platformsDir, AndroidProjectService.ANDROID_PLATFORM_NAME);
42-
if (this.isAndroidStudioCompatibleTemplate(projectData)) {
43-
this.isAndroidStudioTemplate = true;
44-
}
45-
46-
const appDestinationDirectoryArr = [projectRoot];
47-
if (this.isAndroidStudioTemplate) {
48-
appDestinationDirectoryArr.push(constants.APP_FOLDER_NAME);
49-
}
50-
appDestinationDirectoryArr.push(constants.SRC_DIR, constants.MAIN_DIR, constants.ASSETS_DIR);
51-
52-
const configurationsDirectoryArr = [projectRoot];
53-
if (this.isAndroidStudioTemplate) {
54-
configurationsDirectoryArr.push(constants.APP_FOLDER_NAME);
55-
}
56-
configurationsDirectoryArr.push(constants.SRC_DIR, constants.MAIN_DIR, constants.MANIFEST_FILE_NAME);
5739

58-
const deviceBuildOutputArr = [projectRoot];
59-
if (this.isAndroidStudioTemplate) {
60-
deviceBuildOutputArr.push(constants.APP_FOLDER_NAME);
61-
}
62-
deviceBuildOutputArr.push(constants.BUILD_DIR, constants.OUTPUTS_DIR, constants.APK_DIR);
40+
const appDestinationDirectoryArr = [projectRoot, constants.APP_FOLDER_NAME, constants.SRC_DIR, constants.MAIN_DIR, constants.ASSETS_DIR];
41+
const configurationsDirectoryArr = [projectRoot, constants.APP_FOLDER_NAME, constants.SRC_DIR, constants.MAIN_DIR, constants.MANIFEST_FILE_NAME];
42+
const deviceBuildOutputArr = [projectRoot, constants.APP_FOLDER_NAME, constants.BUILD_DIR, constants.OUTPUTS_DIR, constants.APK_DIR];
6343

6444
const packageName = this.getProjectNameFromId(projectData);
6545

@@ -153,30 +133,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
153133
const targetSdkVersion = androidToolsInfo && androidToolsInfo.targetSdkVersion;
154134
this.$logger.trace(`Using Android SDK '${targetSdkVersion}'.`);
155135

156-
this.isAndroidStudioTemplate = this.isAndroidStudioCompatibleTemplate(projectData, frameworkVersion);
157-
if (this.isAndroidStudioTemplate) {
158-
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "*", "-R");
159-
} else {
160-
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "libs", "-R");
161-
162-
if (config.pathToTemplate) {
163-
const mainPath = path.join(this.getPlatformData(projectData).projectRoot, constants.SRC_DIR, constants.MAIN_DIR);
164-
this.$fs.createDirectory(mainPath);
165-
shell.cp("-R", path.join(path.resolve(config.pathToTemplate), "*"), mainPath);
166-
} else {
167-
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, constants.SRC_DIR, "-R");
168-
}
169-
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "build.gradle settings.gradle build-tools", "-Rf");
170-
171-
try {
172-
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "gradle.properties", "-Rf");
173-
} catch (e) {
174-
this.$logger.warn(`\n${e}\nIt's possible, the final .apk file will contain all architectures instead of the ones described in the abiFilters!\nYou can fix this by using the latest android platform.`);
175-
}
176-
177-
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "gradle", "-R");
178-
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "gradlew gradlew.bat", "-f");
179-
}
136+
this.copy(this.getPlatformData(projectData).projectRoot, frameworkDir, "*", "-R");
180137

181138
this.cleanResValues(targetSdkVersion, projectData);
182139
}
@@ -447,38 +404,14 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
447404
}
448405
}
449406

450-
private isAndroidStudioCompatibleTemplate(projectData: IProjectData, frameworkVersion?: string): boolean {
451-
const currentPlatformData: IDictionary<any> = this.$projectDataService.getNSValue(projectData.projectDir, constants.TNS_ANDROID_RUNTIME_NAME);
452-
const platformVersion = (currentPlatformData && currentPlatformData[constants.VERSION_STRING]) || frameworkVersion;
453-
454-
if (!platformVersion) {
455-
return true;
456-
}
457-
458-
if (platformVersion === constants.PackageVersion.NEXT || platformVersion === constants.PackageVersion.LATEST || platformVersion === constants.PackageVersion.RC) {
459-
return true;
460-
}
461-
462-
const androidStudioCompatibleTemplate = "3.4.0";
463-
const normalizedPlatformVersion = `${semver.major(platformVersion)}.${semver.minor(platformVersion)}.0`;
464-
465-
return semver.gte(normalizedPlatformVersion, androidStudioCompatibleTemplate);
466-
}
467-
468407
private getLegacyAppResourcesDestinationDirPath(projectData: IProjectData): string {
469-
const resourcePath: string[] = [constants.SRC_DIR, constants.MAIN_DIR, constants.RESOURCES_DIR];
470-
if (this.isAndroidStudioTemplate) {
471-
resourcePath.unshift(constants.APP_FOLDER_NAME);
472-
}
408+
const resourcePath: string[] = [constants.APP_FOLDER_NAME, constants.SRC_DIR, constants.MAIN_DIR, constants.RESOURCES_DIR];
473409

474410
return path.join(this.getPlatformData(projectData).projectRoot, ...resourcePath);
475411
}
476412

477413
private getUpdatedAppResourcesDestinationDirPath(projectData: IProjectData): string {
478-
const resourcePath: string[] = [constants.SRC_DIR];
479-
if (this.isAndroidStudioTemplate) {
480-
resourcePath.unshift(constants.APP_FOLDER_NAME);
481-
}
414+
const resourcePath: string[] = [constants.APP_FOLDER_NAME, constants.SRC_DIR];
482415

483416
return path.join(this.getPlatformData(projectData).projectRoot, ...resourcePath);
484417
}

0 commit comments

Comments
 (0)