Skip to content

Conversation

@kentakang
Copy link
Contributor

fixes #1784

Summary:

When used with option --port and --deviceId, not working port option on run-android.
The reason is as follows.

run-android with port args.

This command is run with runOnAllDevices function.
runOnAllDevices function is include port argument push on gradle argument logic like below.

if (args.port != null) {
  gradleArgs.push('-PreactNativeDevServerPort=' + args.port);
}

run-android with deviceId args.

This command is run with runOnSpecificDevice function.
but runOnSpecificDevice function is not include port argument logic.

Solution

I added port argument logic on runOnSpecificDevice function like below.

// using '-x lint' in order to ignore linting errors while building the apk
let gradleArgs = ['build', '-x', 'lint'];

if (args.extraParams) {
  gradleArgs = [...gradleArgs, ...args.extraParams];
}

if (args.port) {
  gradleArgs.push(`-PreactNativeDevServerPort=${args.port}`);
}

if (!args.binaryPath) {
  build(gradleArgs, androidProject.sourceDir);
}

installAndLaunchOnDevice(args, deviceId, adbPath, androidProject);

Test Plan:

  • Connect two android device.
  • Link CLI
  • When running the two options together, check that it runs with the port set on the specific device without problems.

Copy link
Collaborator

@adamTrz adamTrz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 💪

@adamTrz adamTrz merged commit dec4a78 into react-native-community:main Dec 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI Can't run with deviceId, port args both

2 participants