Skip to content

fix: run-android device not found on change from deviceId to device #2595

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

Merged
merged 1 commit into from
Feb 12, 2025
Merged
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
16 changes: 8 additions & 8 deletions packages/cli-platform-android/src/commands/runAndroid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ async function buildAndRun(args: Flags, androidProject: AndroidProject) {

if (device.connected) {
return runOnSpecificDevice(
{...args, deviceId: device.deviceId},
{...args, device: device.deviceId},
adbPath,
androidProject,
selectedTask,
Expand All @@ -192,7 +192,7 @@ async function buildAndRun(args: Flags, androidProject: AndroidProject) {
if (result.success) {
logger.info('Successfully launched emulator.');
return runOnSpecificDevice(
{...args, deviceId: emulator},
{...args, device: emulator},
adbPath,
androidProject,
selectedTask,
Expand All @@ -217,7 +217,7 @@ function runOnSpecificDevice(
selectedTask?: string,
) {
const devices = adb.getDevices(adbPath);
const {deviceId} = args;
const {device} = args;

// if coming from run-android command and we have selected task
// from interactive mode we need to create appropriate build task
Expand All @@ -226,8 +226,8 @@ function runOnSpecificDevice(
? [selectedTask.replace('install', 'assemble')]
: [];

if (devices.length > 0 && deviceId) {
if (devices.indexOf(deviceId) !== -1) {
if (devices.length > 0 && device) {
if (devices.indexOf(device) !== -1) {
let gradleArgs = getTaskNames(
androidProject.appName,
args.mode,
Expand All @@ -246,7 +246,7 @@ function runOnSpecificDevice(
}

if (args.activeArchOnly) {
const architecture = adb.getCPU(adbPath, deviceId);
const architecture = adb.getCPU(adbPath, device);

if (architecture !== null) {
logger.info(`Detected architecture ${architecture}`);
Expand All @@ -263,14 +263,14 @@ function runOnSpecificDevice(

installAndLaunchOnDevice(
args,
deviceId,
device,
adbPath,
androidProject,
selectedTask,
);
} else {
logger.error(
`Could not find device with the id: "${deviceId}". Please choose one of the following:`,
`Could not find device: "${device}". Please choose one of the following:`,
...devices,
);
}
Expand Down
Loading