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

[7_1_X][TIMOB-25773] Android: Fixed app build failure caused by " -" in project path #9827

Merged
merged 4 commits into from
Feb 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions android/cli/commands/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -4216,17 +4216,28 @@ AndroidBuilder.prototype.runDexer = function runDexer(next) {
return done();
}

// Double quotes given path and escapes double quote characters in file/directory names.
function quotePath(filePath) {
if (!filePath) {
return '""';
}
if (process.platform !== 'win32') {
filePath = filePath.replace(/"/g, '\\"');
}
return '"' + filePath + '"';
}

// Create a ProGuard config file.
let proguardConfig
= '-dontoptimize\n'
+ '-dontobfuscate\n'
+ '-dontpreverify\n'
+ '-dontwarn **\n'
+ '-libraryjars ' + shrinkedAndroid + '\n';
+ '-libraryjars ' + quotePath(shrinkedAndroid) + '\n';
for (let index = 0; index < injarsCore.length; index++) {
proguardConfig += '-injars ' + injarsCore[index] + '(!META-INF/**)\n';
proguardConfig += '-injars ' + quotePath(injarsCore[index]) + '(!META-INF/**)\n';
}
proguardConfig += '-outjars ' + outjar + '\n';
proguardConfig += '-outjars ' + quotePath(outjar) + '\n';
const mainDexProGuardFilePath = path.join(this.buildDir, 'mainDexProGuard.txt');
fs.writeFileSync(mainDexProGuardFilePath, proguardConfig);

Expand All @@ -4235,11 +4246,11 @@ AndroidBuilder.prototype.runDexer = function runDexer(next) {
// such as the JARs Google provides with Android build-tools v27. Google now acquires the newest
// version of ProGuard via Gradle/Maven, which is kept up to date by the ProGuard maintainers.
const gradleAppFileName = (process.platform === 'win32') ? 'gradlew.bat' : 'gradlew';
appc.subprocess.run(path.join(this.buildDir, gradleAppFileName), [
'-b', path.join(this.buildDir, 'proguard.gradle'),
appc.subprocess.run(quotePath(path.join(this.buildDir, gradleAppFileName)), [
'-b', quotePath(path.join(this.buildDir, 'proguard.gradle')),
'-Pforceprocessing=true',
'-Pconfiguration=' + baserules + pathArraySeparator + mainDexProGuardFilePath
], {}, function (code, out, err) {
'-Pconfiguration=' + quotePath(baserules) + pathArraySeparator + quotePath(mainDexProGuardFilePath)
], { shell: true, windowsHide: true }, function (code, out, err) {
if (code) {
this.logger.error(__('Failed to run dexer:'));
this.logger.error();
Expand Down