Startactivity() is not working

appium - 1.2.2
java-client - 1.7.0
android - 4.4.2
OS - Windows 7
below is the code

DesiredCapabilities capabilities = new DesiredCapabilities();

   capabilities.setCapability("appPackage", "com.android.settings");
 capabilities.setCapability("appActivity", ".Settings");     
     
     capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
     capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, "4.4.2");
       capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 5");
        
     driver = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);

   driver.startActivity("com.android.calculator2",".Calculator","com.android.settings",".Settings");

it shows below error

org.openqa.selenium.UnsupportedCommandException: That URL did not map to a valid JSONWP resource
Command duration or timeout: 8 milliseconds
Build info: version: ‘2.42.2’, revision: ‘6a6995d’, time: ‘2014-06-03 17:42:03’
System info: host: ‘SYS0009’, ip: ‘169.254.247.45’, os.name: ‘Windows 7’, os.arch: ‘amd64’, os.version: ‘6.1’, java.version: ‘1.8.0_20’
Driver info: io.appium.java_client.AppiumDriver
Capabilities [{appPackage=com.android.settings, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, deviceName=Nexus 5, platform=LINUX, appActivity=.Settings, desired={appPackage=com.android.settings, appActivity=.Settings, platformVersion=4.4.2, platformName=Android, udid=077c35ee0ade546b, deviceName=Nexus 5}, platformVersion=4.4.2, webStorageEnabled=false, locationContextEnabled=false, browserName=Android, takesScreenshot=true, javascriptEnabled=true, platformName=Android, udid=077c35ee0ade546b}]
Session ID: e09ce4e0-f3c6-4857-9dcb-c5de2ee5d6e5
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:102)
at io.appium.java_client.AppiumDriver.startActivity(AppiumDriver.java:204)
at Napp.testCal(Napp.java:85)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Following is the log

C:\Users\Raghuram>appium
info: Welcome to Appium v1.2.2 (REV cf6ff5939ddc6b4d45fcbabfbfe13c950e0058c4)
info: Appium REST http interface listener started on 0.0.0.0:4723
info: LogLevel: debug
info: --> POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.android
.settings”,“appActivity”:".Settings",“platformVersion”:“4.4.2”,“platformName”:“A
ndroid”,“deviceName”:“Nexus 5”}}
info: [debug] Didn’t get app but did get Android package, will attempt to launch
it on the device
info: [debug] Creating new appium session d1d46a9b-bd36-4487-bd1a-75b55cc960f7
info: Starting android appium
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s alr
eady on the device
info: [debug] Checking whether adb is present
info: [debug] Using adb from E:\Automation\MobileAutomation\adt\adt-bundle\sdk\p
latform-tools\adb.exe

info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” devices
info: [debug] 1 device(s) connected
info: Found device 077c35ee0ade546b
info: [debug] Setting device id to 077c35ee0ade546b
info: [debug] Waiting for device to be ready and to respond to shell commands (t
imeout = 5)
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b wait-for-device
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “echo ‘ready’”
info: [debug] Starting logcat capture
warn: No app capability, can’t parse package/activity
info: [debug] Getting device API level
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: Device API level is: 19
info: [debug] Apk doesn’t exist locally
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “rm -rf /data/local/tmp/strings.js
on”
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Skipping install since we launched with a package instead of an ap
p path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b push “C:\Users\Raghuram\AppData\Roam
ing\npm\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar” /
data/local/tmp/
info: [debug] Pushing settings apk to device…
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b install “C:\Users\Raghuram\AppData\Roami
ng\npm\node_modules\appium\build\settings_apk\settings_apk-debug.apk”
info: [debug] Pushing unlock helper app to device…
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b install “C:\Users\Raghuram\AppData\Roami
ng\npm\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: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: E:\Automation\MobileAutomation\adt\adt-bundle\sdk\platfo
rm-tools\adb.exe -s 077c35ee0ade546b shell uiautomator runtest AppiumBootstrap.j
ar -c io.appium.android.bootstrap.Bootstrap
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=UiAutomatorTestRun
ner
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.andro
id.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] [BOOTSTRAP] [debug] Registered crash watchers.
info: [debug] Waking up device if it’s not alive
info: [debug] Pushing command to appium work queue: [“wake”,{}]
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] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “dumpsys window”
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:true,“status”:0}
info: [debug] Writing dumpsys output to C:\Users\Raghuram\AppData\Roaming\npm\no
de_modules\appium.dumpsys.log
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] dataDir set to: /data/local/tmp
info: [debug] Getting device API level
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “getprop ro.build.version.sdk”
info: [debug] [BOOTSTRAP] [debug] Returning result: {“value”:"/data/local/tmp
“,“status”:0}
info: [debug] Device is at API Level 19
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “am start -S -a android.intent.act
ion.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.android.settin
gs/.Settings”
info: [debug] Waiting for pkg “com.android.settings” and activity “.Settings” to
be focused
info: [debug] Getting focused package and activity
info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
form-tools\adb.exe” -s 077c35ee0ade546b shell “dumpsys window windows”
info: [debug] Device launched! Ready for commands
info: [debug] Setting command timeout to the default of 60 secs
info: [debug] Appium session started with sessionId d1d46a9b-bd36-4487-bd1a-75b5
5cc960f7
info: <-- POST /wd/hub/session 303 16741.739 ms - 9
info: --> GET /wd/hub/session/d1d46a9b-bd36-4487-bd1a-75b55cc960f7 {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“platform”
:“LINUX”,“browserName”:“Android”,“platformVersion”:“4.4.2”,“webStorageEnabled”:f
alse,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“ne
tworkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desir
ed”:{“appPackage”:“com.android.settings”,“appActivity”:”.Settings",“platformVers
ion”:“4.4.2”,“platformName”:“Android”,“deviceName”:“Nexus 5”},“appPackage”:“com.
android.settings”,“appActivity”:".Settings",“platformName”:“Android”,"deviceName
":“Nexus 5”},“sessionId”:“d1d46a9b-bd36-4487-bd1a-75b55cc960f7”}
info: <-- GET /wd/hub/session/d1d46a9b-bd36-4487-bd1a-75b55cc960f7 200 3.941 ms

  • 575 {“status”:0,“value”:{“platform”:“LINUX”,“browserName”:“Android”,“platformV
    ersion”:“4.4.2”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnab
    led”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationConte
    xtEnabled”:false,“warnings”:{},“desired”:{“appPackage”:“com.android.settings”,“a
    ppActivity”:".Settings",“platformVersion”:“4.4.2”,“platformName”:“Android”,“devi
    ceName”:“Nexus 5”},“appPackage”:“com.android.settings”,“appActivity”:".Settings"
    ,“platformName”:“Android”,“deviceName”:“Nexus 5”},“sessionId”:“d1d46a9b-bd36-448
    7-bd1a-75b55cc960f7”}
    info: --> POST /wd/hub/session/d1d46a9b-bd36-4487-bd1a-75b55cc960f7/appium/devic
    e/start_activity {“appPackage”:“com.android.calculator2”,“appActivity”:".Calcula
    tor",“appWaitPackage”:“com.android.settings”,“appWaitActivity”:".Settings"}
    info: [debug] Responding to client that we did not find a valid resource
    info: <-- POST /wd/hub/session/d1d46a9b-bd36-4487-bd1a-75b55cc960f7/appium/devic
    e/start_activity 404 9.730 ms - 47
    info: --> DELETE /wd/hub/session/d1d46a9b-bd36-4487-bd1a-75b55cc960f7 {}
    info: Shutting down appium session
    info: [debug] Pressing the HOME button
    info: [debug] executing: “E:\Automation\MobileAutomation\adt\adt-bundle\sdk\plat
    form-tools\adb.exe” -s 077c35ee0ade546b shell “input keyevent 3”
    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=UiAutomatorTestRun
    ner
    info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
    info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.andro
    id.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 shut down normally
    info: [debug] Cleaning up android objects
    info: [debug] Cleaning up appium session
    info: [debug] Responding to client with success: {“status”:0,“value”:null,“sessi
    onId”:“d1d46a9b-bd36-4487-bd1a-75b55cc960f7”}
    info: <-- DELETE /wd/hub/session/d1d46a9b-bd36-4487-bd1a-75b55cc960f7 200 756.65
    2 ms - 76 {“status”:0,“value”:null,“sessionId”:“d1d46a9b-bd36-4487-bd1a-75b55cc9
    60f7”}
    info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
    info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
    info: [debug] [UIAUTOMATOR STDOUT] Time: 11.995
    info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
    info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
1 Like

I am facing the same problem on Win7

Yeah! It seems that it is solved in 1.2.3. Proof link

StartActivity does not exist in 1.2.2 or earlier. It is a new 1.2.3 feature.