diff --git a/packages/cli-platform-android/src/commands/runAndroid/__tests__/tryLaunchAppOnDevice.test.ts b/packages/cli-platform-android/src/commands/runAndroid/__tests__/tryLaunchAppOnDevice.test.ts index 39630bcdf..4520d4bd7 100644 --- a/packages/cli-platform-android/src/commands/runAndroid/__tests__/tryLaunchAppOnDevice.test.ts +++ b/packages/cli-platform-android/src/commands/runAndroid/__tests__/tryLaunchAppOnDevice.test.ts @@ -59,6 +59,28 @@ test('launches adb shell with intent to launch com.myapp.MainActivity with diffe ); }); +test('launches adb shell with intent to launch com.myapp.MainActivity with different appId than packageName on a simulator when mainActivity is fully qualified name', () => { + tryLaunchAppOnDevice( + device, + {...androidProject, mainActivity: 'com.myapp.MainActivity'}, + adbPath, + args, + ); + + expect(execa.sync).toHaveBeenCalledWith( + 'path/to/adb', + [ + '-s', + 'emulator-5554', + ...shellStartCommand, + '-n', + 'com.myapp.custom/com.myapp.MainActivity', + ...actionCategoryFlags, + ], + {stdio: 'inherit'}, + ); +}); + test('launches adb shell with intent to launch com.myapp.MainActivity with same appId as packageName on a simulator', () => { tryLaunchAppOnDevice( device, diff --git a/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts b/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts index 2a0dda4a0..cd9241353 100644 --- a/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts +++ b/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts @@ -24,7 +24,9 @@ function tryLaunchAppOnDevice( .filter(Boolean) .join('.'); - const activityToLaunch = mainActivity.includes('.') + const activityToLaunch = mainActivity.startsWith(packageName) + ? mainActivity + : mainActivity.startsWith('.') ? [packageName, mainActivity].join('') : [packageName, mainActivity].filter(Boolean).join('.');