Getting Error info: [debug] Error: Activity used to start app doesn't exist or cannot be launched! Make sure it exists and is a launchable activity

Hi All,

I am getting an error in Appium while running it using selenium and testNG, Appium launch’s app (Wordpress) but wont proceed to the next step.I have pasted the error below , can anyone please help me to debug it.

Appium Error:
nfo: [debug] Error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity

at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1146:21)
at [object Object].<anonymous> (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:635:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity)”,“origValue”:“Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity”},“sessionId”:null}

Configuration:

File classpathRoot = new File(System.getProperty(“user.dir”));
File appDir = new File(classpathRoot, “/app”);
File app = new File(appDir, “org.wordpress.android-4.1-APK4Fun.com.apk”);

        DesiredCapabilities capabilities = new DesiredCapabilities();  
        capabilities.setCapability("deviceName", "emulator-5554");
        capabilities.setCapability("browserName", "");   
        capabilities.setCapability("platformVersion", "5.1");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("app", app.getAbsolutePath());
        capabilities.setCapability("appPackage", "org.wordpress.android");
        capabilities.setCapability("appActivity", "Dashboard");
        capabilities.setCapability("appWaitActivity", "Dashboard");
            driver =  new RemoteWebDriver( new URL( "http://127.0.0.1:4723/wd/hub" ), capabilities );
        driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS);

Your app path looks weird. Is it really “/app”?

Here’s a good article on absolute vs relative paths:

Hi Wreed,

Thanks for the replay but I am using absolute path, the application is being installed in the emulator through Appium but its not launching the application.

The error console says, its not able to launch the activity.

One reason could be its not the launcher activity. Are you sure its the first activity or Launcher Main activity?

Can you paste more appium server logs ?

RamS,

I am pasting the appium logs below,

nfo: Starting App

info: [debug] Attempting to kill all ‘uiautomator’ processes
info: [debug] Getting all processes with ‘uiautomator’
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg org.wordpress.android -e disableAndroidWatchers false
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724
info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready
info: [debug] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
info: [debug] [BOOTSTRAP] [debug] Loading json…
info: [debug] [BOOTSTRAP] [debug] json loading complete.
info: [debug] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] [BOOTSTRAP] [debug] Client connected
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“wake”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: wake
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “dumpsys window”
info: [debug] [BOOTSTRAP] [debug] Emitting system alert message
info: [debug] Emitting alert message…
info: Unlocking screen
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “dumpsys window”
info: [debug] Screen is locked, trying to unlock
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.unlock/.Unlock”
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “dumpsys window”
info: [debug] Screen is unlocked, continuing
info: [debug] Pushing command to appium work queue: [“getDataDir”,{}]
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“getDataDir”,“params”:{}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] dataDir set to: /data
info: [debug] Pushing command to appium work queue: [“compressedLayoutHierarchy”,{“compressLayout”:false}]
info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“/data”}
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“compressedLayoutHierarchy”,“params”:{“compressLayout”:false}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:false}
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n org.wordpress.android/Dashboard”
info: [debug] We tried to start an activity that doesn’t exist, retrying with . prepended to activity
info: [debug] Getting device API level
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 22
info: [debug] executing cmd: C:\Users\Nagendra\AppData\Local\Android\sdk\platform-tools\adb.exe -s emulator-5554 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n org.wordpress.android/.Dashboard”
info: [debug] Stopping logcat capture
error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“shutdown”}
info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:“OK, shutting down”}
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] [BOOTSTRAP] [debug] Closed client connection
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=.
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 31.649
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] UiAutomator shut down normally
error: Failed to start an Appium session, err was: Error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
info: [debug] Error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1146:21)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:635:7)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity)”,“origValue”:“Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity”},“sessionId”:null}

This is where its failing.

Can you try the following :

  1. Install the app on to your device manually

  2. Launch app from command line - adb shell am start -n org.wordpress.android/org.wordpress.android.Dashboard

  3. Launch app from command line using Launcher Activity : am start -a android.intent.action.MAIN -n org.wordpress.android/Dashboard

Rams,

I checked manually in command prompt I am getting the app doesn’t exists, message.Can you please help me what has to be done as a next step.

I am pasting the output of command prompt.

Error type 3
Error: Activity class {
tivity} does not exist.

Do you have access to source code/ android manifest file of your application.

You can get details of Launcher / Main activity from that file.

If not you may want to use an app called apkinfo from googleplay store to get these details.

Please note , the package name of your Dashboard activity may be different from your app package. Get the correct package name for launcher activity.

Ram S

Thanks for the suggestion but I am getting the similar error message for a local app, even though the launch activity is given as in the local app.

One Question?

Is Maven required for appium. I have seen some youtube videos they have used Maven I didn’t used Maven in my framework so I am getting confused with this.

No, Maven is not needed unless you are building your test project maven style [with POM to add dependencies]

The problem you are facing is related to ADB not able to find Activity which we are passing in command line.
If you are not able to launch app using simple ADB command from command line, it means your activity package name is not correct.It is even not related to appium. Its plain adb command.

I would suggest you to install app manually on to device using command -
adb install {application path}

Then install apk info from playstore. Open APK info application and get details of the package name of application. and Package name of Dashboard activity.

Then run this command from commandline -

adb shell am start -n {application package name}/{dashboard activity package name}.Dashboard

Thanks RamS, for the suggestions.

I ran the above command from command line, its giving me an error
Starting: Intent { cmp=com.example.
Error type 3
Error: Activity class {com.example.
ashActivity} does not exist.

But I commented the launch activity command from capabilities it ran successfully, still in command prompt I am getting the above mentioned error.I am not getting what would be the reason.

Usually the reason would be, package name of the Launcher activity is not correct.
Do you have access to Android.manifest file of the application? You can get these details from that file.

Also, please note the package name of the application and package name of the Activity can be different. So please double check this.

1 Like

Hello.
I am getting the same error, but I assume that appActivity name is correct. I am not able to start the app from Appium server.

info: [debug] Error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity
at [object Object]. (C:\Program Files\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:1146:21)
at [object Object]. (C:\Program Files\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:180:9)
at ChildProcess.exithandler (child_process.js:742:7)
at ChildProcess.emit (events.js:110:17)
at maybeClose (child_process.js:1016:16)
at Process.ChildProcess._handle.onexit (child_process.js:1088:5)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity)”,“origValue”:“Activity used to start app doesn’t exist or cannot be launched! Make sure it exists and is a launchable activity”},“sessionId”:null}

When I run

adb shell am start -n {application package name}/{dashboard activity package name}

then the app started.

I installed the app with adb command.

UPDATE:

Ok, I manage to solve it. I needlesly were sending “app=AppName” to the server. Without it (just sending appPackage and appActivity) it works.

Use ‘apppackage’ instead of ‘appPackage’ and ‘appactivity’ instead of ‘appActivity’

1 Like

use ‘appactivity’ in stead of ‘appActivity’ and ‘apppackage’ in stead of ‘appPackage’ while setting Compatibility

changing the capitalisation of the capability fields broke things further for me , as did removing the path to the app file

This thing worked ‘appActivity’ and ‘apppackage’ in stead of ‘appPackage’ while setting Compatibility,