Skip to content

Commit 4b475f7

Browse files
authored
clean-up after release build in android to prevent runtime errors (#2452)
1 parent c220cc0 commit 4b475f7

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

lib/definitions/project.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ interface IPlatformProjectService {
163163
* @returns {void}
164164
*/
165165
ensureConfigurationFileInAppResources(): void;
166+
167+
/**
168+
* Removes build artifacts specific to the platform
169+
* @returns {void}
170+
*/
171+
cleanProject(projectRoot: string, options: string[]): IFuture<void>
166172
}
167173

168174
interface IAndroidProjectPropertiesManager {

lib/services/android-project-service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ export class AndroidProjectService extends projectServiceBaseLib.PlatformProject
410410
return Future.fromResult();
411411
}
412412

413-
private cleanProject(projectRoot: string, options: string[]): IFuture<void> {
413+
public cleanProject(projectRoot: string, options: string[]): IFuture<void> {
414414
return (() => {
415415
options.unshift("clean");
416416

lib/services/ios-project-service.ts

+5
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,15 @@ We will now place an empty obsolete compatability white screen LauncScreen.xib f
653653
this.platformData.configurationFileName
654654
);
655655
}
656+
656657
public ensureConfigurationFileInAppResources(): void {
657658
return null;
658659
}
659660

661+
public cleanProject(projectRoot: string, options: string[]): IFuture<void> {
662+
return Future.fromResult();
663+
}
664+
660665
private mergeInfoPlists(): IFuture<void> {
661666
return (() => {
662667
let projectDir = this.$projectData.projectDir;

lib/services/platform-service.ts

+10
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,16 @@ export class PlatformService implements IPlatformService {
217217
this.ensurePlatformInstalled(platform).wait();
218218
let changesInfo = this.$projectChangesService.checkForChanges(platform);
219219
if (changesInfo.hasChanges) {
220+
// android build artifacts need to be cleaned up when switching from release to debug builds
221+
if (platform.toLowerCase() === "android") {
222+
let previousPrepareInfo = this.$projectChangesService.getPrepareInfo(platform);
223+
// clean up prepared plugins when not building for release
224+
if (previousPrepareInfo && previousPrepareInfo.release !== this.$options.release) {
225+
let platformData = this.$platformsData.getPlatformData(platform);
226+
platformData.platformProjectService.cleanProject(platformData.projectRoot, []).wait();
227+
}
228+
}
229+
220230
this.preparePlatformCore(platform, changesInfo).wait();
221231
this.$projectChangesService.savePrepareInfo(platform);
222232
} else {

test/stubs.ts

+3
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ export class PlatformProjectServiceStub implements IPlatformProjectService {
338338
ensureConfigurationFileInAppResources(): void {
339339
return null;
340340
}
341+
cleanProject(projectRoot: string, options: string[]): IFuture<void> {
342+
return Future.fromResult();
343+
}
341344
}
342345

343346
export class ProjectDataService implements IProjectDataService {

0 commit comments

Comments
 (0)