Skip to content

Commit 5302c0e

Browse files
Fix emulator port issue by removing explicit port assignment
- Remove default port from action.yml to avoid forcing port 5554 - Allow emulator to auto-assign port instead of explicit -port parameter - Keep default port for ADB commands but don't force emulator port
1 parent 1dcd009 commit 5302c0e

File tree

5 files changed

+21
-9
lines changed

5 files changed

+21
-9
lines changed

action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ inputs:
4141
default: '600'
4242
emulator-port:
4343
description: 'Port to run emulator on, allows to run multiple emulators on the same physical machine'
44-
default: '5554'
4544
emulator-options:
4645
description: 'command-line options used when launching the emulator - e.g. `-no-window -no-snapshot -camera-back emulated`'
4746
default: '-no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim'

lib/emulator-manager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function launchEmulator(systemImageApiLevel, target, arch, profile, cores, ramSi
7272
}
7373
// start emulator
7474
console.log('Starting emulator.');
75-
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -avd "${avdName}" ${emulatorOptions} &"`, [], {
75+
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
7676
listeners: {
7777
stderr: (data) => {
7878
if (data.toString().includes('invalid command-line parameter')) {

lib/main.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,16 @@ function run() {
108108
const emulatorBootTimeout = parseInt(core.getInput('emulator-boot-timeout'), 10);
109109
console.log(`Emulator boot timeout: ${emulatorBootTimeout}`);
110110
// Emulator port to use
111-
port = parseInt(core.getInput('emulator-port'), 10);
112-
(0, input_validator_1.checkPort)(port);
113-
console.log(`emulator port: ${port}`);
111+
const emulatorPortInput = core.getInput('emulator-port');
112+
if (emulatorPortInput) {
113+
port = parseInt(emulatorPortInput, 10);
114+
(0, input_validator_1.checkPort)(port);
115+
console.log(`emulator port: ${port}`);
116+
}
117+
else {
118+
port = input_validator_1.MIN_PORT; // Use default port when none specified
119+
console.log(`emulator port: ${port} (default)`);
120+
}
114121
// emulator options
115122
const emulatorOptions = core.getInput('emulator-options').trim();
116123
console.log(`emulator options: ${emulatorOptions}`);

src/emulator-manager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export async function launchEmulator(
6666
// start emulator
6767
console.log('Starting emulator.');
6868

69-
await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -avd "${avdName}" ${emulatorOptions} &"`, [], {
69+
await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -avd "${avdName}" ${emulatorOptions} &"`, [], {
7070
listeners: {
7171
stderr: (data: Buffer) => {
7272
if (data.toString().includes('invalid command-line parameter')) {

src/main.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,15 @@ async function run() {
101101
console.log(`Emulator boot timeout: ${emulatorBootTimeout}`);
102102

103103
// Emulator port to use
104-
port = parseInt(core.getInput('emulator-port'), 10);
105-
checkPort(port);
106-
console.log(`emulator port: ${port}`);
104+
const emulatorPortInput = core.getInput('emulator-port');
105+
if (emulatorPortInput) {
106+
port = parseInt(emulatorPortInput, 10);
107+
checkPort(port);
108+
console.log(`emulator port: ${port}`);
109+
} else {
110+
port = MIN_PORT; // Use default port when none specified
111+
console.log(`emulator port: ${port} (default)`);
112+
}
107113

108114
// emulator options
109115
const emulatorOptions = core.getInput('emulator-options').trim();

0 commit comments

Comments
 (0)