diff --git a/lib/commands/app-management.js b/lib/commands/app-management.js index e8cfa247..b756ec47 100644 --- a/lib/commands/app-management.js +++ b/lib/commands/app-management.js @@ -5,6 +5,7 @@ import { APP_STATE } from '../android-helpers'; import { errors } from 'appium/driver'; const APP_EXTENSIONS = ['.apk', '.apks']; +const RESOLVER_ACTIVITY_NAME = 'android/com.android.internal.app.ResolverActivity'; let commands = {}; @@ -77,6 +78,16 @@ commands.activateApp = async function activateApp (appId) { return; } + let activityName = await this.adb.resolveLaunchableActivity(appId); + if (activityName === RESOLVER_ACTIVITY_NAME) { + // https://github.com/appium/appium/issues/17128 + this.log.debug( + `The launchable activity name of '${appId}' was resolved to '${activityName}'. ` + + `Switching the resolver to not use cmd` + ); + activityName = await this.adb.resolveLaunchableActivity(appId, {preferCmd: false}); + } + const stdout = await this.adb.shell([ 'am', (apiLevel < 26) ? 'start' : 'start-activity', '-a', 'android.intent.action.MAIN', @@ -85,7 +96,7 @@ commands.activateApp = async function activateApp (appId) { // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_NEW_TASK // https://developer.android.com/reference/android/content/Intent#FLAG_ACTIVITY_RESET_TASK_IF_NEEDED '-f', '0x10200000', - '-n', await this.adb.resolveLaunchableActivity(appId), + '-n', activityName, ]); this.log.debug(stdout); if (/^error:/mi.test(stdout)) { diff --git a/package.json b/package.json index 2d63bb76..50af303d 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ ], "dependencies": { "@babel/runtime": "^7.0.0", - "appium-adb": "^9.6.0", + "appium-adb": "^9.9.0", "appium-chromedriver": "^5.0.1", "asyncbox": "^2.8.0", "axios": "^0.x",