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(cli): apkName for multi-dimensional flavors #7347

Merged
merged 1 commit into from
Mar 14, 2024
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
8 changes: 6 additions & 2 deletions cli/src/android/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import Debug from 'debug';
import { resolve } from 'path';

import c from '../colors';
import { promptForPlatformTarget, runTask } from '../common';
import {
promptForPlatformTarget,
parseApkNameFromFlavor,
runTask,
} from '../common';
import type { Config } from '../definitions';
import type { RunCommandOptions } from '../tasks/run';
import { runNativeRun, getPlatformTargets } from '../util/native-run';
Expand Down Expand Up @@ -50,7 +54,7 @@ export async function runAndroid(
config.android.appDir
}/build/outputs/apk${runFlavor !== '' ? '/' + runFlavor : ''}/debug`;

const apkName = `app${runFlavor !== '' ? '-' + runFlavor : ''}-debug.apk`;
const apkName = parseApkNameFromFlavor(runFlavor);

const apkPath = resolve(pathToApk, apkName);

Expand Down
5 changes: 5 additions & 0 deletions cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,8 @@ export async function checkJDKMajorVersion(): Promise<number> {
return -1;
}
}

export function parseApkNameFromFlavor(flavor: string): string {
const convertedName = flavor.replace(/([A-Z])/g, '-$1').toLowerCase();
return `app-${convertedName ? `${convertedName}-` : ''}debug.apk`;
}
5 changes: 2 additions & 3 deletions cli/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Debug from 'debug';
import { dirname, extname, join, relative, resolve } from 'path';

import c from './colors';
import { parseApkNameFromFlavor } from './common';
import type {
AndroidConfig,
AppConfig,
Expand Down Expand Up @@ -247,13 +248,11 @@ async function loadAndroidConfig(
const webDir = `${assetsDir}/public`;
const resDir = `${srcMainDir}/res`;
let apkPath = `${appDir}/build/outputs/apk/`;
let flavorPrefix = '';
const flavor = extConfig.android?.flavor || '';
if (extConfig.android?.flavor) {
apkPath = `${apkPath}/${extConfig.android?.flavor}`;
flavorPrefix = `-${extConfig.android?.flavor}`;
}
const apkName = `app${flavorPrefix}-debug.apk`;
const apkName = parseApkNameFromFlavor(flavor);
const buildOutputDir = `${apkPath}/debug`;
const cordovaPluginsDir = 'capacitor-cordova-android-plugins';
const studioPath = lazy(() => determineAndroidStudioPath(cliConfig.os));
Expand Down
Loading