From a5b7c820018dc0570a13447ddad890a2faef9532 Mon Sep 17 00:00:00 2001 From: Ben Delaney Date: Fri, 29 Jan 2021 20:44:16 +1100 Subject: [PATCH] Delete android files on build type change to force copy to app --- publish/scripts/installer.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/publish/scripts/installer.js b/publish/scripts/installer.js index 5aae77f0..18475dcd 100755 --- a/publish/scripts/installer.js +++ b/publish/scripts/installer.js @@ -881,6 +881,20 @@ module.exports = function($logger, hookArgs) { if (forcePrepare) { $logger.info('nativescript-plugin-firebase: running release build or change in environment detected, forcing prepare!'); + const googleServicesValuesXmlPath = path.join(platformsDir, platform, "app", "build", "generated", "res", "google-services", isReleaseBuild ? "release" : "debug", "values") + const mergeDebugResourcesPath = path.join(platformsDir, platform, "app", "build", "intermediates", "incremental", isReleaseBuild ? "mergeReleaseResources" : "mergeDebugResources") + + // The following files must be deleted for the google-services.json change to actually be reflected in the app + if (fs.existsSync(path.join(googleServicesValuesXmlPath, "values.xml"))) { + fs.unlinkSync(path.join(googleServicesValuesXmlPath, "values.xml")) + } + if (fs.existsSync(path.join(mergeDebugResourcesPath, "merger.xml"))) { + fs.unlinkSync(path.join(mergeDebugResourcesPath, "merger.xml")) + } + if (fs.existsSync(path.join(mergeDebugResourcesPath, "merged.dir", "values", "values.xml"))) { + fs.unlinkSync(path.join(mergeDebugResourcesPath, "merged.dir", "values", "values.xml")) + } + if (fs.existsSync(npfInfoPath)) { fs.unlinkSync(npfInfoPath); } if (fs.existsSync(nsPrepareInfoPath)) { fs.unlinkSync(nsPrepareInfoPath); }