Skip to content

Commit 9796295

Browse files
shockdesignfacebook-github-bot
authored andcommitted
Allow applicationId to be specified on build
Summary: Added the ability to define a specific applicationId (in case it's different to the package name) <details> Thanks for submitting a PR! Please read these instructions carefully: - [x] Explain the **motivation** for making this change. - [ ] Provide a **test plan** demonstrating that the code is solid. - [x] Match the **code formatting** of the rest of the codebase. - [x] Target the `master` branch, NOT a "stable" branch. Please read the [Contribution Guidelines](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md) to learn more about contributing to React Native. </details> We have a specific requirement that our package name differs from the applicationId but not in a way that allows us to add it as a suffix to our package name. I wanted to add the option to specify a specific applicationId. `react-native run-android --appId <Specific Application Id>` Closes facebook#14524 Differential Revision: D5910259 Pulled By: shergin fbshipit-source-id: 768fbc910f6b520dd18936f6bceeee136fca7025
1 parent c70ac24 commit 9796295

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

local-cli/runAndroid/runAndroid.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ function tryRunAdbReverse(packagerPort, device) {
8888
}
8989
}
9090

91+
function getPackageNameWithSuffix(appId, appIdSuffix, packageName) {
92+
if (appId) {
93+
return appId;
94+
} else if (appIdSuffix) {
95+
return packageName + '.' + appIdSuffix;
96+
}
97+
98+
return packageName;
99+
}
100+
91101
// Builds the app and runs it on a connected emulator / device.
92102
function buildAndRun(args) {
93103
process.chdir(path.join(args.root, 'android'));
@@ -100,7 +110,7 @@ function buildAndRun(args) {
100110
'utf8'
101111
).match(/package="(.+?)"/)[1];
102112

103-
const packageNameWithSuffix = args.appIdSuffix ? packageName + '.' + args.appIdSuffix : packageName;
113+
const packageNameWithSuffix = getPackageNameWithSuffix(args.appId, args.appIdSuffix, packageName);
104114

105115
const adbPath = getAdbPath();
106116
if (args.deviceId) {
@@ -302,6 +312,10 @@ module.exports = {
302312
command: '--appFolder [string]',
303313
description: 'Specify a different application folder name for the android source.',
304314
default: 'app',
315+
}, {
316+
command: '--appId [string]',
317+
description: 'Specify an applicationId to launch after build.',
318+
default: '',
305319
}, {
306320
command: '--appIdSuffix [string]',
307321
description: 'Specify an applicationIdSuffix to launch after build.',

0 commit comments

Comments
 (0)