Skip to content

device.launchApp() fails on Android emulator with exit status 251 for both app-under-test and system apps #82

@chikhanh123

Description

@chikhanh123

Mobilewright version

0.0.30

Operating system

MacOs

Target platform

Android

Device or simulator

simulator

Minimal reproduction

Summary

On Android emulator, device.launchApp() fails consistently in Mobilewright/mobilecli with exit status 251.
This reproduces not only with our app (kh.com.ibank.rdbuat) but also with a clean repro using Android Settings (com.android.settings) in a brand new project created via npx mobilewright init.

This suggests the issue is in the Android app launch path of Mobilewright/mobilecli, not in the target app or project setup.

Environment

Mobilewright: 0.0.30
@mobilewright/test: 0.0.30
@playwright/test: 1.58.2
Driver: default mobilecli
Android device id in Mobilewright: pixel
Device type: Android emulator
Android version: 14
Host: macOS
Mobilecli doctor detects the device successfully
Reproduction

Create a fresh project:
mkdir mobilewright-init-smoke
cd mobilewright-init-smoke
npx mobilewright init
npm init -y
npm install -D mobilewright@0.0.30 @mobilewright/test@0.0.30 @playwright/test@1.58.2 typescript@5.9.3
Use this config:
import { defineConfig } from 'mobilewright';

export default defineConfig({
platform: 'android',
bundleId: 'com.android.settings',
deviceId: 'pixel',
timeout: 30_000,
});
Use this test:
import { test, expect } from '@mobilewright/test';

test('launches Android Settings from init sample', async ({ device }) => {
const foregroundApp = await device.getForegroundApp();
expect(foregroundApp.bundleId).toBe('com.android.settings');
});
Run:
MW_PLATFORM=android MW_DEVICE_ID=pixel playwright test --config=mobilewright.config.ts

Actual behavior

Test fails during app launch with:

RpcError: failed to launch app on device pixel: failed to launch app com.android.settings: exit status 251
Output: bash arg: -p
bash arg: com.android.settings
bash arg: -c
bash arg: android.intent.category.LAUNCHER
bash arg: 1
args: [-p, com.android.settings, -c, android.intent.category.LAUNCHER, 1]
arg: "-p"
arg: "com.android.settings"
arg: "-c"
arg: "android.intent.category.LAUNCHER"
arg: "1"
data="com.android.settings"
data="android.intent.category.LAUNCHER"
** SYS_KEYS has no physical keys but with factor 2.0%.

Expected behavior

Expected Result

device.launchApp('com.android.settings') should foreground Android Settings successfully.

Additional context

Additional Notes

The same failure also happens with our app under test: kh.com.ibank.rdbuat
adb can launch the same apps successfully on the same emulator, for example:
adb -s emulator-5554 shell am start -S -n com.android.settings/.Settings
and for our app:

adb -s emulator-5554 shell am start -S -n kh.com.ibank.rdbuat/kh.com.ibank.rdb.MainActivity
So the app/emulator is healthy; the failure seems specific to Mobilewright/mobilecli’s Android launch mechanism.

Why this looks like a framework issue

Reproduces in a fresh npx mobilewright init project
Reproduces with a system app, not just a business app
Reproduces before any custom locator/test logic is involved
adb launch works on the same emulator

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions