Android Launch already installed App

Any one please please help me in launching the already installed app in the device

I will be happy if anyone paste code.

Python Code:
To launch your own app just edit the values in appPackage and appActivity.
This script launches Youtube application in your Android Device.

Type adb devices in your terminal to check if your Android device shows up before performing any of the steps.

Step 1: Save the below code in your local hard drive with filename.py
Step 2: Start Appium server in your System before running this code [Command: Appium &]
Step 3: Open a new terminal > navigate to the file location via terminal and type python filename.py

In the device you can see the Youtube app opening automatically :smile:

import os
import unittest
from appium import webdriver
from time import sleep

class YoutubeAndroidTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps[ā€˜platformNameā€™] = ā€˜Androidā€™
desired_caps[ā€˜platformVersionā€™] = ā€˜4.3ā€™
desired_caps[ā€˜deviceNameā€™] = ā€˜Samsung S3ā€™
desired_caps[ā€˜appPackageā€™] = ā€˜com.google.android.youtubeā€™
desired_caps[ā€˜appActivityā€™] = ā€˜com.google.android.youtube.HomeActivityā€™

    self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

def tearDown(self):
    self.driver.quit()

def test_add_listings(self):
    self.driver.implicitly_wait(150)

if name == ā€˜mainā€™:
suite = unittest.TestLoader().loadTestsFromTestCase(YoutubeAndroidTests)
unittest.TextTestRunner(verbosity=2).run(suite)

By default, your app will be launched by appium, using teh capabilities you pass on to Appium driver [appPackage and appActivity[]

If you are looking at something like below scenario -

  1. As part of the test, you sign out of the app
  2. You want to re-launch the app.

driver,launchApp() ideally should work.

I am using the below code, but the app is not launched

File app = new File(ā€œG://Ravi testing/Apps/Demo.apkā€);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.BROWSER_NAME, ā€œā€);
capabilities.setCapability(ā€œdeviceNameā€,ā€œHT35JW912039ā€);
//capabilities.setCapability(ā€œdeviceNameā€, ā€œTestā€);
capabilities.setCapability(ā€œautomationNameā€,ā€œandroid-appā€);
capabilities.setCapability(ā€œplatformNameā€, ā€œAndroidā€);
capabilities.setCapability(ā€œappā€, app.getAbsolutePath());
capabilities.setCapability(ā€œapp-packageā€, ā€œPackage nameā€);
capabilities.setCapability(ā€œapp-activityā€, ā€œActivityā€);
capabilities.setCapability(ā€œtakesScreenshotā€, true);
//driver= new RemoteWebDriver( new URL(ā€œhttp://127.0.0.1:4723/wd/hubā€), capabilities);
driver= new AndroidDriver( new URL(ā€œhttp://127.0.0.1:4723/wd/hubā€), capabilities) ;

Try the following - Please make sure to put right String value in capabilities [platformVersion, appPackage, appActivity]

    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
    desiredCapabilities.setCapability("deviceName", "HT35JW912039");
    desiredCapabilities.setCapability("platformName", "android");
    desiredCapabilities.setCapability("platformVersion", "4.4.4");
    desiredCapabilities.setCapability("app", "G://Ravi testing/Apps/Demo.apk");
    desiredCapabilities.setCapability("appPackage", "packageName");
    desiredCapabilities.setCapability("appActivity", "activityName");

    String host = "127.0.0.1";
    String port = "4723";
    
    try {
    	mDriver = new AndroidDriver(
                new URL("http://" + host + ":" + port + "/wd/hub"),
                desiredCapabilities);
    }
    catch(Exception e) {
    	
    }

Tried same code by changing package name and activity name, but no luck Ramā€¦

Can you please paste the Appium error logs from server.

Also, can you share details of Appium server version and client version.

Console Error:

[TestNG] Running:
C:\Users\RAVI\AppData\Local\Temp\testng-eclipseā€“789315402\testng-customsuite.xml

SignIn started
Verifying Lots in watchlist
Adding Lot to watchlist started
FAILED: Signin
java.lang.NullPointerException
at copart.AddingLotToWatchlist.Signin(AddingLotToWatchlist.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

FAILED: VerifyWatchlist
java.lang.NullPointerException
at copart.AddingLotToWatchlist.VerifyWatchlist(AddingLotToWatchlist.java:75)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

FAILED: Signout
java.lang.NullPointerException
at copart.AddingLotToWatchlist.Signout(AddingLotToWatchlist.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

FAILED: Watchlist
java.lang.NullPointerException
at copart.AddingLotToWatchlist.Watchlist(AddingLotToWatchlist.java:90)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

===============================================
Default test
Tests run: 4, Failures: 4, Skips: 0

These are your test NG logs.
Can you share Appium server logs.

I am just guessing all these null pointer may be due to driver being null [not properly created]

Appium Console

Checking if an update is available
Update not available
Starting Node Server
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {ā€œaddressā€:ā€œ127.0.0.1ā€,ā€œlogNoColorsā€:true,ā€œplatformNameā€:ā€œAndroidā€,ā€œplatformVersionā€:ā€œ18ā€,ā€œautomationNameā€:ā€œAppiumā€}
info: Console LogLevel: debug
info: ā†’ POST /wd/hub/session {ā€œdesiredCapabilitiesā€:{ā€œappā€:ā€œE://Android/Apks/copart.apkā€,ā€œappPackageā€:ā€œcom.popcorn.copartappā€,ā€œappActivityā€:ā€œactivityNamecom.popcorn.copartapp.CopartSplashScreenā€,ā€œplatformVersionā€:ā€œ4.4.2ā€,ā€œplatformNameā€:ā€œAndroidā€,ā€œdeviceNameā€:ā€œ42031c94b43da100ā€}}
info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.8.0_45)
info: [debug] Using local app from desired caps: E:\Android\Apks\copart.apk
info: [debug] Creating new appium session d14e69bc-2368-44d6-b496-121016d73ca0
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_45
info: [debug] Checking whether adb is present
info: [debug] Using adb from E:\Android\android-sdk-windows\platform-tools\adb.exe
info: [debug] Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devicesā€¦
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 42031c94b43da100
info: [debug] Setting device id to 42031c94b43da100
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 wait-for-device
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œecho ā€˜readyā€™ā€
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop persist.sys.languageā€
info: [debug] Current device persist.sys.language: en
info: [debug] java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jarā€ ā€œstringsFromApkā€ ā€œE:\Android\Apks\copart.apkā€ ā€œC:\Users\RAVI\AppData\Local\Temp\com.popcorn.copartappā€ en
info: [debug] No strings.xml for language ā€˜enā€™, getting default strings.xml
info: [debug] java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jarā€ ā€œstringsFromApkā€ ā€œE:\Android\Apks\copart.apkā€ ā€œC:\Users\RAVI\AppData\Local\Temp\com.popcorn.copartappā€
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 push ā€œC:\Users\RAVI\AppData\Local\Temp\com.popcorn.copartapp\strings.jsonā€ /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from E:\Android\android-sdk-windows\build-tools\22.0.1\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: E:\Android\android-sdk-windows\build-tools\22.0.1\aapt.exe dump xmltree E:\Android\Apks\copart.apk AndroidManifest.xml
info: [debug] Set app process to: com.popcorn.copartapp
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for E:\Android\Apks\copart.apk.
info: [debug] executing cmd: java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jarā€ E:\Android\Apks\copart.apk
info: [debug] App already signed.
info: [debug] Zip-aligning E:\Android\Apks\copart.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from E:\Android\android-sdk-windows\build-tools\22.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: E:\Android\android-sdk-windows\build-tools\22.0.1\zipalign.exe -f 4 E:\Android\Apks\copart.apk C:\Users\RAVI\AppData\Local\Temp\11564-2380-79aipq\appium.tmp
info: [debug] MD5 for app is 040386c14a6fe0ab35788193a2a74572
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œls /data/local/tmp/040386c14a6fe0ab35788193a2a74572.apkā€
info: [debug] Getting install status for com.popcorn.copartapp
info: [debug] Getting device API level
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 19
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œpm list packages -3 com.popcorn.copartappā€
info: [debug] App is not installed
info: Installing App
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œmkdir -p /data/local/tmp/ā€
info: [debug] Removing any old apks
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œls /data/local/tmp/*.apkā€
info: [debug] Found an apk we want to keep at /data/local/tmp/040386c14a6fe0ab35788193a2a74572.apk
info: [debug] Couldnā€™t find any apks to remove
info: [debug] Uninstalling com.popcorn.copartapp
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œam force-stop com.popcorn.copartappā€
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 uninstall com.popcorn.copartapp
info: [debug] App was not uninstalled, maybe it wasnā€™t on device?
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œpm install -r /data/local/tmp/040386c14a6fe0ab35788193a2a74572.apkā€
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to deviceā€¦
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 push ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jarā€ /data/local/tmp/
info: [debug] Pushing settings apk to deviceā€¦
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 install ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apkā€

Your appium server log seem to be incomplete, as it does not point out at actual error.

Looking at above part in log, your ā€œappActivityā€ value looks be incorrect. I believe, it should be com.popcorn.copartapp.CopartSplashScreen , but has additional text activityName at the beginning.

Can you paste remaining server logs and also code snippet where you create DesiredCapabilities object.

Capabilities COde

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
// desiredCapabilities.setCapability(ā€œdeviceNameā€, ā€œHT35JW912039ā€);
desiredCapabilities.setCapability(ā€œdeviceNameā€,ā€œ42031c94b43da100ā€); // HTC
desiredCapabilities.setCapability(ā€œplatformNameā€, ā€œandroidā€);
desiredCapabilities.setCapability(ā€œplatformVersionā€, ā€œ4.4.2ā€);
desiredCapabilities.setCapability(ā€œappā€, ā€œE://Android/Apks/copart.apkā€);
desiredCapabilities.setCapability(ā€œappPackageā€, ā€œcom.popcorn.copartappā€);
desiredCapabilities.setCapability(ā€œappActivityā€, ā€œcom.popcorn.copartapp.CopartSplashScreenā€);

String host = "127.0.0.1";
String port = "4723";

try {
	mDriver = new AndroidDriver(
            new URL("http://" + host + ":" + port + "/wd/hub"),
            desiredCapabilities);
}
catch(Exception e) {
	
}
System.out.println("App launched");

Appium Log

Starting Node Server
warn: Appium support for versions of node < 0.12 has been deprecated and will be removed in a future version. Please upgrade!
info: Welcome to Appium v1.4.0 (REV 8f63e2f91ef7907aed8bda763f4e5ca08e86970a)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {ā€œaddressā€:ā€œ127.0.0.1ā€,ā€œlogNoColorsā€:true,ā€œplatformNameā€:ā€œAndroidā€,ā€œplatformVersionā€:ā€œ18ā€,ā€œautomationNameā€:ā€œAppiumā€}
info: Console LogLevel: debug
info: ā†’ POST /wd/hub/session {ā€œdesiredCapabilitiesā€:{ā€œappā€:ā€œE://Android/Apks/copart.apkā€,ā€œappPackageā€:ā€œcom.popcorn.copartappā€,ā€œappActivityā€:ā€œcom.popcorn.copartapp.CopartSplashScreenā€,ā€œplatformVersionā€:ā€œ4.4.2ā€,ā€œplatformNameā€:ā€œAndroidā€,ā€œdeviceNameā€:ā€œ42031c94b43da100ā€}}
info: Client User-Agent string: Apache-HttpClient/4.4.1 (Java/1.8.0_45)
info: [debug] Using local app from desired caps: E:\Android\Apks\copart.apk
info: [debug] Creating new appium session 37dfaa74-4680-4d08-ab38-e9a0bb06e630
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_45
info: [debug] Checking whether adb is present
info: [debug] Using adb from E:\Android\android-sdk-windows\platform-tools\adb.exe
info: [debug] Set chromedriver binary as: C:\Program Files (x86)\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devicesā€¦
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device 42031c94b43da100
info: [debug] Setting device id to 42031c94b43da100
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 wait-for-device
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œecho ā€˜readyā€™ā€
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop persist.sys.languageā€
info: [debug] Current device persist.sys.language: en
info: [debug] java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jarā€ ā€œstringsFromApkā€ ā€œE:\Android\Apks\copart.apkā€ ā€œC:\Users\RAVI\AppData\Local\Temp\com.popcorn.copartappā€ en
info: [debug] No strings.xml for language ā€˜enā€™, getting default strings.xml
info: [debug] java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jarā€ ā€œstringsFromApkā€ ā€œE:\Android\Apks\copart.apkā€ ā€œC:\Users\RAVI\AppData\Local\Temp\com.popcorn.copartappā€
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 push ā€œC:\Users\RAVI\AppData\Local\Temp\com.popcorn.copartapp\strings.jsonā€ /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from E:\Android\android-sdk-windows\build-tools\22.0.1\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: E:\Android\android-sdk-windows\build-tools\22.0.1\aapt.exe dump xmltree E:\Android\Apks\copart.apk AndroidManifest.xml
info: [debug] Set app process to: com.popcorn.copartapp
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for E:\Android\Apks\copart.apk.
info: [debug] executing cmd: java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jarā€ E:\Android\Apks\copart.apk
info: [debug] App already signed.
info: [debug] Zip-aligning E:\Android\Apks\copart.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from E:\Android\android-sdk-windows\build-tools\22.0.1\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: E:\Android\android-sdk-windows\build-tools\22.0.1\zipalign.exe -f 4 E:\Android\Apks\copart.apk C:\Users\RAVI\AppData\Local\Temp\11565-2508-1j6amgm\appium.tmp
info: [debug] MD5 for app is 040386c14a6fe0ab35788193a2a74572
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œls /data/local/tmp/040386c14a6fe0ab35788193a2a74572.apkā€
info: [debug] Getting install status for com.popcorn.copartapp
info: [debug] Getting device API level
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 19
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œpm list packages -3 com.popcorn.copartappā€
info: [debug] App is not installed
info: Installing App
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œmkdir -p /data/local/tmp/ā€
info: [debug] Removing any old apks
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œls /data/local/tmp/*.apkā€
info: [debug] Found an apk we want to keep at /data/local/tmp/040386c14a6fe0ab35788193a2a74572.apk
info: [debug] Couldnā€™t find any apks to remove
info: [debug] Uninstalling com.popcorn.copartapp
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œam force-stop com.popcorn.copartappā€
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 uninstall com.popcorn.copartapp
info: [debug] App was not uninstalled, maybe it wasnā€™t on device?
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œpm install -r /data/local/tmp/040386c14a6fe0ab35788193a2a74572.apkā€
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to deviceā€¦
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 push ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jarā€ /data/local/tmp/
info: [debug] Pushing settings apk to deviceā€¦
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 install ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apkā€
info: [debug] Pushing unlock helper app to deviceā€¦
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 install ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apkā€
info: Starting App
info: [debug] Attempting to kill all ā€˜uiautomatorā€™ processes
info: [debug] Getting all processes with ā€˜uiautomatorā€™
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œps ā€˜uiautomatorā€™ā€
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg com.popcorn.copartapp -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] [BOOTSTRAP] [debug] Loading jsonā€¦
info: [debug] Waking up device if itā€™s not alive
info: [debug] Pushing command to appium work queue: [ā€œwakeā€,{}]
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: {ā€œvalueā€:true,ā€œstatusā€:0}
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œdumpsys windowā€
info: [debug] Screen already 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] [BOOTSTRAP] [debug] Got command action: getDataDir
info: [debug] [BOOTSTRAP] [debug] Returning result: {ā€œvalueā€:ā€œ/data/local/tmpā€,ā€œstatusā€:0}
info: [debug] dataDir set to: /data/local/tmp
info: [debug] Pushing command to appium work queue: [ā€œcompressedLayoutHierarchyā€,{ā€œcompressLayoutā€:false}]
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: {ā€œvalueā€:false,ā€œstatusā€:0}
info: [debug] Getting device API level
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 19
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œam start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.popcorn.copartapp/com.popcorn.copartapp.CopartSplashScreenā€
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: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 19
info: [debug] executing cmd: E:\Android\android-sdk-windows\platform-tools\adb.exe -s 42031c94b43da100 shell ā€œam start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.popcorn.copartapp/.com.popcorn.copartapp.CopartSplashScreenā€
error: Activity used to start app doesnā€™t exist or cannot be launched! Make sure it exists and is a launchable activity
info: [debug] Stopping logcat capture
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: {ā€œvalueā€:ā€œOK, shutting downā€,ā€œstatusā€:0}
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] Sent shutdown command, waiting for UiAutomator to stopā€¦
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 4.366
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}
info: ā† POST /wd/hub/session 500 77406.440 ms - 346

The activity name you passed as a start activity is not correct.

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 command line -

 adb shell am start -n {application package name}/{Launcher activity package name}.activityName

ex : adb shell am start -n com.popcorn.copartapp/com.x.y.activitypackagename.activityName

Similar discussion is ongoing at thread - 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 - #10 by RamS

1 Like

Thanks Ram. It worked.

Hi Ram & Ravi

I am getting same problem and unable to launch android application.
I have tried all the methods and get nothing on any blog or anywhere.
Please see my logs and code and help me outā€¦ i am totally stucked and very new to Appium

Appium Logs:

info: ā†’ POST /wd/hub/session {ā€œdesiredCapabilitiesā€:{ā€œappā€:ā€œD:\Appium\Whatsapp\WhatsApp.apkā€,ā€œappPackageā€:ā€œcom.whatsappā€,ā€œappActivityā€:ā€œcom.whatsapp.Mainā€,ā€œplatformVersionā€:ā€œ6.0ā€,ā€œbrowserNameā€:ā€œā€,ā€œplatformNameā€:ā€œAndroidā€,ā€œdeviceNameā€:ā€œMi498HA14090346ā€}}
info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_66)
info: [debug] Using local app from desired caps: D:\Appium\Whatsapp\WhatsApp.apk
info: [debug] Creating new appium session 9bf0c62d-b4ac-454a-938b-dfc46b4e9afc
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_66
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\Cherrey\sdk\platform-tools\adb.exe
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devicesā€¦
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: Found device sp7731c21005c070464
info: [debug] Setting device id to sp7731c21005c070464
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 wait-for-device
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œecho ā€˜readyā€™ā€
info: [debug] Starting logcat capture
info: [debug] Getting device API level
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 23
info: Device API level is: 23
info: [debug] Extracting strings for language: default
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œgetprop persist.sys.languageā€
info: [debug] Current device persist.sys.language:
info: [debug] java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jarā€ ā€œstringsFromApkā€ ā€œD:\Appium\Whatsapp\WhatsApp.apkā€ ā€œC:\Users\RISHAB~1.JAI\AppData\Local\Temp\com.whatsappā€
info: [debug] Reading strings from converted strings.json
info: [debug] Setting language to default
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 push ā€œC:\Users\RISHAB~1.JAI\AppData\Local\Temp\com.whatsapp\strings.jsonā€ /data/local/tmp
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\Cherrey\sdk\build-tools\android-4.4W\aapt.exe
info: [debug] Retrieving process from manifest.
info: [debug] executing cmd: D:\Cherrey\sdk\build-tools\android-4.4W\aapt.exe dump xmltree D:\Appium\Whatsapp\WhatsApp.apk AndroidManifest.xml
info: [debug] Set app process to: com.whatsapp
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for D:\Appium\Whatsapp\WhatsApp.apk.
info: [debug] executing cmd: java -jar ā€œC:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jarā€ D:\Appium\Whatsapp\WhatsApp.apk
info: [debug] App already signed.
info: [debug] Zip-aligning D:\Appium\Whatsapp\WhatsApp.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\Cherrey\sdk\build-tools\android-4.4W\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\Cherrey\sdk\build-tools\android-4.4W\zipalign.exe -f 4 D:\Appium\Whatsapp\WhatsApp.apk C:\Users\RISHAB~1.JAI\AppData\Local\Temp\116112-15112-nqoy3v\appium.tmp
info: [debug] MD5 for app is 4fb3cc813bcf5837bf8e009648edebd9
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œls /data/local/tmp/4fb3cc813bcf5837bf8e009648edebd9.apkā€
info: [debug] Getting install status for com.whatsapp
info: [debug] Getting device API level
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œgetprop ro.build.version.sdkā€
info: [debug] Device is at API Level 23
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œpm list packages -3 com.whatsappā€
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œam force-stop com.whatsappā€
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 shell ā€œpm clear com.whatsappā€
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to deviceā€¦
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 push ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jarā€ /data/local/tmp/
info: [debug] Pushing settings apk to deviceā€¦
info: [debug] executing cmd: D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 install ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apkā€
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Sent shutdown command, waiting for UiAutomator to stopā€¦
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: C:\Windows\system32\cmd.exe /s /c ā€œD:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 install ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apkā€ā€

info: [debug] Error: Command failed: C:\Windows\system32\cmd.exe /s /c ā€œD:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 install ā€œC:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apkā€ā€

at ChildProcess.exithandler (child_process.js:751:12)
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: Command failed: C:\Windows\system32\cmd.exe /s /c "D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk""\n)ā€,ā€œkilledā€:false,ā€œcodeā€:3221226356,ā€œsignalā€:null,ā€œcmdā€:ā€œC:\Windows\system32\cmd.exe /s /c "D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk""ā€,ā€œorigValueā€:ā€œCommand failed: C:\Windows\system32\cmd.exe /s /c "D:\Cherrey\sdk\platform-tools\adb.exe -s sp7731c21005c070464 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk""\nā€},ā€œsessionIdā€:null}
info: ā† POST /wd/hub/session 500 24140.098 ms - 862

Code:
private static AndroidDriver driver = null;

public static void main(String g[]) throws MalformedURLException,InterruptedException
{
	File app = new File("D://Appium//Whatsapp//WhatsApp.apk");
	DesiredCapabilities cap = new DesiredCapabilities();
	cap.setCapability(CapabilityType.BROWSER_NAME, "");
	cap.setCapability("deviceName", "Mi498HA14090346");
	cap.setCapability("platformName", "Android");
	//cap.setCapability("automationName", "android-app");
	cap.setCapability("platformVersion", "6.0");	
	cap.setCapability("app", app.getAbsolutePath());
	cap.setCapability("appPackage", "com.whatsapp");
	cap.setCapability("appActivity", "com.whatsapp.Main");
	
	//driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),cap);

	String host = "127.0.0.1";
    String port = "4723";
    
    try {
    	driver = new AndroidDriver(
                new URL("http://" + host + ":" + port + "/wd/hub"),
                cap);
    }
    catch(Exception e) {
    	
    }
    System.out.println("APP Launched");
	driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
	Thread.sleep(10000);
	driver.quit();

I had a similar issue. I just wanted to open an existing app in my phone and i think I finally sorted out by adding the parameters in the capabilities setting in my java code. See below:

File appDir = new File("apk");
File app = new File(appDir, "ums.apk");

DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("device", "Android");

// mandatory capabilities
capabilities.setCapability("deviceName", "Nexus5Android5");
capabilities.setCapability("platformName", "Android");

// other caps
//capabilities.setCapability("app", app.getAbsolutePath());
// capabilities.setCapability("app", appUrl);

**//Open the app without installing it**
capabilities.setCapability("appPackage", "nz.co.airnz.mobile.unaccompaniedminors");
capabilities.setCapability("appActivity", "activity.StartUpActivity");

My problem now is that because im using a real device, the app could have a user logged in or not when i run the test. If there is an existing user logged into the app, my test fails because the first test i run is a login test and obviously it wonā€™t find the elements in the screen.

Is there any parameter I can use to force any to logout automatically?

I have tried the ā€˜Override existing sessionā€™ parameter in Appium but this doesnā€™t work because itā€™s related to the server session, not the app session.

Any help would be appreciated.

Thanks.

Is that possible to launch app using ADB SHELL using Appium? If I use appPackage & appActivity to pass values its launching but after that got crashed, so Just thinking to use Shell command instead of these launching Capabilities.

Please someone help me on this.

Can you add these capabilities and try

	capabilities.setCapability("noReset",true);
	capabilities.setCapability("fullReset",false);
1 Like

this work for me

{
  "platformName": "Android",
  "deviceName": "Android",
  "automationName": "Appium",
  "appPackage": "com.bla.blah.automation",
  "appActivity": "com.bla.blah.splash.SplashScreenActivity",
  "noReset": true,
  "fullReset": false,
  "dontStopAppOnReset": false
}