Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion lib/emulator-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,13 @@ function launchEmulator(apiLevel, target, arch, profile, cores, ramSize, heapSiz
console.log('Disabling Linux hardware acceleration.');
emulatorOptions += ' -accel off';
}
let emulatorCommandPrefix;
if (process.platform === 'linux') {
emulatorCommandPrefix = 'xvfb-run';
}
// start emulator
console.log('Starting emulator.');
yield exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -avd "${avdName}" ${emulatorOptions} &"`, [], {
yield exec.exec(`sh -c \\"${emulatorCommandPrefix} ${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -avd "${avdName}" ${emulatorOptions} &"`, [], {
listeners: {
stderr: (data) => {
if (data.toString().includes('invalid command-line parameter')) {
Expand Down
6 changes: 6 additions & 0 deletions lib/sdk-installer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk
console.log(`::group::Install Android SDK`);
const isOnMac = process.platform === 'darwin';
const isArm = process.arch === 'arm64';
const isLinux = process.platform === 'linux';
if (!isOnMac) {
yield exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
}
Expand Down Expand Up @@ -106,6 +107,11 @@ function installAndroidSdk(apiLevel, target, arch, channelId, emulatorBuild, ndk
console.log(`Installing CMake ${cmakeVersion}.`);
yield exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' --channel=${channelId} > /dev/null"`);
}
if (isLinux) {
console.log('Installing emulator dependencies.');
yield exec.exec(`sh -c \\"sudo apt update"`);
yield exec.exec(`sh -c \\"sudo apt install libpulse0 xvfb"`);
}
}
finally {
console.log(`::endgroup::`);
Expand Down
8 changes: 7 additions & 1 deletion src/emulator-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,16 @@ export async function launchEmulator(
emulatorOptions += ' -accel off';
}

let emulatorCommandPrefix;

if (process.platform === 'linux') {
emulatorCommandPrefix = 'xvfb-run'
}

// start emulator
console.log('Starting emulator.');

await exec.exec(`sh -c \\"${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -avd "${avdName}" ${emulatorOptions} &"`, [], {
await exec.exec(`sh -c \\"${emulatorCommandPrefix} ${process.env.ANDROID_HOME}/emulator/emulator -port ${port} -avd "${avdName}" ${emulatorOptions} &"`, [], {
listeners: {
stderr: (data: Buffer) => {
if (data.toString().includes('invalid command-line parameter')) {
Expand Down
6 changes: 6 additions & 0 deletions src/sdk-installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
console.log(`::group::Install Android SDK`);
const isOnMac = process.platform === 'darwin';
const isArm = process.arch === 'arm64';
const isLinux = process.platform === 'linux';

if (!isOnMac) {
await exec.exec(`sh -c \\"sudo chown $USER:$USER ${process.env.ANDROID_HOME} -R`);
Expand Down Expand Up @@ -79,6 +80,11 @@ export async function installAndroidSdk(apiLevel: string, target: string, arch:
console.log(`Installing CMake ${cmakeVersion}.`);
await exec.exec(`sh -c \\"sdkmanager --install 'cmake;${cmakeVersion}' --channel=${channelId} > /dev/null"`);
}
if (isLinux) {
console.log('Installing emulator dependencies.');
await exec.exec(`sh -c \\"sudo apt update"`)
await exec.exec(`sh -c \\"sudo apt install libpulse0 xvfb"`)
}
} finally {
console.log(`::endgroup::`);
}
Expand Down