Allow configuring the app source folder for android
Summary: I have been working on integrating React Native into an existing app and realised that the source folder for android code is currently hardcoded as `app`. Being a legacy codebase we can't really change that. So I wanted to be able to customise this folder name so that I can integrate RN seamlessly and start it from the CLI without having to run it from Android Studio. - Create a barebones RN app - `react-native run-android` works successfully - Refactor the name of the app folder inside the android directory to `TestFolderName` using Android Studio - `react-native run-android` now fails - Changing this command to `react-native run-android --appFolder=TestFolderName` works successfully Closes https://github.com/facebook/react-native/pull/13273 Differential Revision: D4833396 Pulled By: ericvicenti fbshipit-source-id: 4c62cee6aaa2cc78eede5c7756459430022fffde
This commit is contained in:
parent
9d1c62669b
commit
840dc0cc82
|
@ -86,7 +86,7 @@ function buildAndRun(args) {
|
|||
: './gradlew';
|
||||
|
||||
const packageName = fs.readFileSync(
|
||||
'app/src/main/AndroidManifest.xml',
|
||||
`${args.appFolder}/src/main/AndroidManifest.xml`,
|
||||
'utf8'
|
||||
).match(/package="(.+?)"/)[1];
|
||||
|
||||
|
@ -135,7 +135,7 @@ function buildApk(gradlew) {
|
|||
|
||||
function tryInstallAppOnDevice(args, device) {
|
||||
try {
|
||||
const pathToApk = 'app/build/outputs/apk/app-debug.apk';
|
||||
const pathToApk = `${args.appFolder}/build/outputs/apk/${args.appFolder}-debug.apk`;
|
||||
const adbPath = getAdbPath();
|
||||
const adbArgs = ['-s', device, 'install', pathToApk];
|
||||
console.log(chalk.bold(
|
||||
|
@ -288,6 +288,10 @@ module.exports = {
|
|||
description: '--flavor has been deprecated. Use --variant instead',
|
||||
}, {
|
||||
command: '--variant [string]',
|
||||
}, {
|
||||
command: '--appFolder [string]',
|
||||
description: 'Specify a different application folder name for the android source.',
|
||||
default: 'app',
|
||||
}, {
|
||||
command: '--appIdSuffix [string]',
|
||||
description: 'Specify an applicationIdSuffix to launch after build.',
|
||||
|
|
Loading…
Reference in New Issue