Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android)(9_0_X): production builds no longer copy AAB to distribution folder as of 9.0.1 #11645

Merged
merged 4 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3689,7 +3689,15 @@ AndroidBuilder.prototype.buildAppProject = async function buildAppProject() {

// Set path to the app-bundle file that was built up above.
// Our "package.js" event hook will later copy it to the developer's chosen destination directory.
this.aabFile = path.join(this.buildDir, 'app', 'build', 'outputs', 'bundle', 'release', 'app.aab');
this.aabFile = path.join(this.buildDir, 'app', 'build', 'outputs', 'bundle', 'release', 'app-release.aab');
}

// Verify that we can find the above built file(s).
if (!await fs.exists(this.apkFile)) {
throw new Error(`Failed to find built APK file: ${this.apkFile}`);
}
if (this.aabFile && !await fs.exists(this.aabFile)) {
throw new Error(`Failed to find built AAB file: ${this.aabFile}`);
}
};

Expand Down
34 changes: 13 additions & 21 deletions android/cli/hooks/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,32 @@ exports.init = function (logger, config, cli) {
return finished();
}

// Fetch a path to the built APK file.
let sourceFilePath = builder.apkFile;
if (!sourceFilePath || !fs.existsSync(sourceFilePath)) {
logger.error(__('No APK file to deploy, skipping'));
return finished();
}

// Do not continue if developer did not provide a destination directory.
const outputDir = builder.outputDir;
if (!outputDir) {
logger.error(__('Packaging output directory path cannot be empty.'));
return finished();
}

// Copy built app file(s) to destination directory.
if (outputDir !== path.dirname(sourceFilePath)) {
// Create the destination directory.
fs.ensureDirSync(outputDir);
// Create the destination directory.
fs.ensureDirSync(outputDir);

// Copy built APK to destination.
let outputFilePath = path.join(outputDir, builder.tiapp.name + '.apk');
// Copy built APK to destination, if available.
if (builder.apkFile && fs.existsSync(builder.apkFile)) {
const outputFilePath = path.join(outputDir, builder.tiapp.name + '.apk');
if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath);
}
appc.fs.copyFileSync(sourceFilePath, outputFilePath, { logger: logger.debug });
appc.fs.copyFileSync(builder.apkFile, outputFilePath, { logger: logger.debug });
}

// Copy built app-bundle to destination, if available.
if (builder.aabFile && fs.existsSync(builder.aabFile)) {
outputFilePath = path.join(outputDir, builder.tiapp.name + '.aab');
if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath);
}
appc.fs.copyFileSync(builder.aabFile, outputFilePath, { logger: logger.debug });
// Copy built app-bundle to destination, if available.
if (builder.aabFile && fs.existsSync(builder.aabFile)) {
const outputFilePath = path.join(outputDir, builder.tiapp.name + '.aab');
if (fs.existsSync(outputFilePath)) {
fs.unlinkSync(outputFilePath);
}
appc.fs.copyFileSync(builder.aabFile, outputFilePath, { logger: logger.debug });
}

logger.info(__('Packaging complete'));
Expand Down