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 4520d4bd7..404f7c36e 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 @@ -118,6 +118,34 @@ test('launches adb shell with intent to launch com.myapp.MainActivity with diffe ); }); +test('launches adb shell with intent to launch fully specified activity with different appId than packageName and an app suffix on a device', () => { + tryLaunchAppOnDevice( + device, + { + ...androidProject, + mainActivity: 'com.zoontek.rnbootsplash.RNBootSplashActivity', + }, + adbPath, + { + ...args, + appIdSuffix: 'dev', + }, + ); + + expect(execa.sync).toHaveBeenCalledWith( + 'path/to/adb', + [ + '-s', + 'emulator-5554', + ...shellStartCommand, + '-n', + 'com.myapp.custom.dev/com.zoontek.rnbootsplash.RNBootSplashActivity', + ...actionCategoryFlags, + ], + {stdio: 'inherit'}, + ); +}); + test('--appId flag overwrites applicationId setting in androidProject', () => { tryLaunchAppOnDevice(undefined, androidProject, adbPath, { ...args, diff --git a/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts b/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts index cd9241353..dfb53e9d9 100644 --- a/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts +++ b/packages/cli-platform-android/src/commands/runAndroid/tryLaunchAppOnDevice.ts @@ -24,11 +24,13 @@ function tryLaunchAppOnDevice( .filter(Boolean) .join('.'); - const activityToLaunch = mainActivity.startsWith(packageName) - ? mainActivity - : mainActivity.startsWith('.') - ? [packageName, mainActivity].join('') - : [packageName, mainActivity].filter(Boolean).join('.'); + const activityToLaunch = + mainActivity.startsWith(packageName) || + (!mainActivity.startsWith('.') && mainActivity.includes('.')) + ? mainActivity + : mainActivity.startsWith('.') + ? [packageName, mainActivity].join('') + : [packageName, mainActivity].filter(Boolean).join('.'); try { // Here we're using the same flags as Android Studio to launch the app