@@ -5,6 +5,7 @@ import { APP_STATE } from '../android-helpers';
55import { errors } from 'appium/driver' ;
66
77const APP_EXTENSIONS = [ '.apk' , '.apks' ] ;
8+ const RESOLVER_ACTIVITY_NAME = 'android/com.android.internal.app.ResolverActivity' ;
89
910let commands = { } ;
1011
@@ -77,6 +78,16 @@ commands.activateApp = async function activateApp (appId) {
7778 return ;
7879 }
7980
81+ let activityName = await this . adb . resolveLaunchableActivity ( appId ) ;
82+ if ( activityName === RESOLVER_ACTIVITY_NAME ) {
83+ // https://github.com/appium/appium/issues/17128
84+ this . log . debug (
85+ `The launchable activity name of '${ appId } ' was resolved to '${ activityName } '. ` +
86+ `Switching the resolver to not use cmd`
87+ ) ;
88+ activityName = await this . adb . resolveLaunchableActivity ( appId , { preferCmd : false } ) ;
89+ }
90+
8091 const stdout = await this . adb . shell ( [
8192 'am' , ( apiLevel < 26 ) ? 'start' : 'start-activity' ,
8293 '-a' , 'android.intent.action.MAIN' ,
@@ -85,7 +96,7 @@ commands.activateApp = async function activateApp (appId) {
8596 // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_TASK
8697 // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
8798 '-f' , '0x10200000' ,
88- '-n' , await this . adb . resolveLaunchableActivity ( appId ) ,
99+ '-n' , activityName ,
89100 ] ) ;
90101 this . log . debug ( stdout ) ;
91102 if ( / ^ e r r o r : / mi. test ( stdout ) ) {
0 commit comments