diff --git a/lib/definitions/project.d.ts b/lib/definitions/project.d.ts index c839ce8ea2..35a26e80eb 100644 --- a/lib/definitions/project.d.ts +++ b/lib/definitions/project.d.ts @@ -163,6 +163,12 @@ interface IPlatformProjectService { * @returns {void} */ ensureConfigurationFileInAppResources(): void; + + /** + * Removes build artifacts specific to the platform + * @returns {void} + */ + cleanProject(projectRoot: string, options: string[]): IFuture } interface IAndroidProjectPropertiesManager { diff --git a/lib/services/android-project-service.ts b/lib/services/android-project-service.ts index e96f8b4f1f..8cff73a657 100644 --- a/lib/services/android-project-service.ts +++ b/lib/services/android-project-service.ts @@ -410,7 +410,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject return Future.fromResult(); } - private cleanProject(projectRoot: string, options: string[]): IFuture { + public cleanProject(projectRoot: string, options: string[]): IFuture { return (() => { options.unshift("clean"); diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 5876d8342f..b433a85e6b 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -653,10 +653,15 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f this.platformData.configurationFileName ); } + public ensureConfigurationFileInAppResources(): void { return null; } + public cleanProject(projectRoot: string, options: string[]): IFuture { + return Future.fromResult(); + } + private mergeInfoPlists(): IFuture { return (() => { let projectDir = this.$projectData.projectDir; diff --git a/lib/services/platform-service.ts b/lib/services/platform-service.ts index 2ffbabcb41..0978dbcee8 100644 --- a/lib/services/platform-service.ts +++ b/lib/services/platform-service.ts @@ -217,6 +217,16 @@ export class PlatformService implements IPlatformService { this.ensurePlatformInstalled(platform).wait(); let changesInfo = this.$projectChangesService.checkForChanges(platform); if (changesInfo.hasChanges) { + // android build artifacts need to be cleaned up when switching from release to debug builds + if (platform.toLowerCase() === "android") { + let previousPrepareInfo = this.$projectChangesService.getPrepareInfo(platform); + // clean up prepared plugins when not building for release + if (previousPrepareInfo && previousPrepareInfo.release !== this.$options.release) { + let platformData = this.$platformsData.getPlatformData(platform); + platformData.platformProjectService.cleanProject(platformData.projectRoot, []).wait(); + } + } + this.preparePlatformCore(platform, changesInfo).wait(); this.$projectChangesService.savePrepareInfo(platform); } else { diff --git a/test/stubs.ts b/test/stubs.ts index 9e40df9377..708904ac2e 100644 --- a/test/stubs.ts +++ b/test/stubs.ts @@ -338,6 +338,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService { ensureConfigurationFileInAppResources(): void { return null; } + cleanProject(projectRoot: string, options: string[]): IFuture { + return Future.fromResult(); + } } export class ProjectDataService implements IProjectDataService {