Cannot run a basic appium code

Hi,
could anybody please check my Appium log and maybe tell me whats the Problem!
I can’t run a basic code.I can’t find where the problem is… just help me ASAP…
All other information are correct,i have cross-checked also…

My log is

info: [debug] Could not get strings, but it looks like we had an old strings file anyway, so ignoring
info: [debug] executing cmd: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 shell “rm -rf /data/local/tmp/strings.json”
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 app path
info: [debug] Forwarding system:4724 to device:4724
info: [debug] executing cmd: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 forward tcp:4724 tcp:4724
info: [debug] Pushing appium bootstrap to device…
info: [debug] executing cmd: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 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: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 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: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 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: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 shell “ps ‘uiautomator’”
info: [debug] No matching processes found
info: [debug] Running bootstrap
info: [debug] spawning: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg /system/priv-app/Settings.apk -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] 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: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 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: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing cmd: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n /system/priv-app/Settings.apk/com.android.settings.Settings”
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\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 19
info: [debug] executing cmd: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 09e4a5b3 shell “am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n /system/priv-app/Settings.apk/.com.android.settings.Settings”
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] Sent shutdown command, waiting for UiAutomator to stop…
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] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=.
info: [debug] [UIAUTOMATOR STDOUT] Time: 2.502
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 5872.118 ms - 346

Stop and start the appium, then try to run the script. May be session already exists.

i tried it multiple times

what is version of android

i tried with 4.4 and 5.0

paste your code here

package Android;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class SimpleAndroidCalcTest {

WebDriver driver;

@BeforeTest
public void setUp() throws MalformedURLException {
// Created object of DesiredCapabilities class.
DesiredCapabilities capabilities = new DesiredCapabilities();

// Set android deviceName desired capability. Set your device name.
capabilities.setCapability(“deviceName”, “09e4a5b3”);

// Set BROWSER_NAME desired capability. It’s Android in our case here.
capabilities.setCapability(CapabilityType.BROWSER_NAME, “Android”);

// Set android VERSION desired capability. Set your mobile device’s OS version.
capabilities.setCapability(CapabilityType.VERSION, “4.4.4”);

// Set android platformName desired capability. It’s Android in our case here.
capabilities.setCapability(“platformName”, “Android”);

// Set android appPackage desired capability. It is
// com.android.calculator2 for calculator application.
// Set your application’s appPackage if you are using any other app.
capabilities.setCapability(“appPackage”, “/system/app/Calculator.apk”);

// Set android appActivity desired capability. It is
// com.android.calculator2.Calculator for calculator application.
// Set your application’s appPackage if you are using any other app.
capabilities.setCapability(“appActivity”, “com.android.calculator2.Calculator”);

// Created object of RemoteWebDriver will all set capabilities.
// Set appium server address and port number in URL string.
// It will launch calculator app in android device.
driver = new RemoteWebDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
}

@Test
public void Sum() {
driver.findElements(By.xpath("//android.widget.Button")).get(0).click();
driver.findElement(By.name(“2”)).click();
driver.findElement(By.name("+")).click();
driver.findElement(By.name(“5”)).click();
driver.findElement(By.name("=")).click();
String result = driver.findElement(By.className(“android.widget.EditText”)).getText();
System.out.println("Number sum result is : " + result);

}

Instead of above

capabilities.setCapability(“deviceName”, “Lenovo”); // give the name shown in device, setting> about phone
capabilities.setCapability(“platformVersion”, “4.4.4”);

Hope your are try to run the app.

Also check this is correct … capabilities.setCapability(“appPackage”, “/system/app/Calculator.apk”);

Same behavior is appeared when i try to change the device name and platform version

For this - capabilities.setCapability(“appPackage”, “/system/app/Calculator.apk”); i used apk info.app to get details…is it correct?

Are you sure that the below line is correct?
capabilities.setCapability(“appActivity”, “com.android.calculator2.Calculator”);

What version of the Appium Server are you running? If 1.5.3, I don’t think you can use “name” as a locator strategy.

Hi,
i have modified my code,but now i am getting this error…can u help me

\appium-jsonwp-proxy\node_modules\babel-runtime\regenerator\runtime.js:136:37)

at bound (domain.js:284:14)
at GeneratorFunctionPrototype.runBound (domain.js:297:12)
at run (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\es6.promise.js:89:39)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\es6.promise.js:100:28
at flush (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\node_modules\appium-jsonwp-proxy\node_modules\babel-runtime\node_modules\core-js\library\modules\$.microtask.js:17:13)
at process._tickDomainCallback (node.js:381:11)

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: A new session could not be created. (Original error: session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid ‘context’: {"auxData":{"frameId":"1567.1","isDefault":true},"id":1,"name":"","origin":"://"}\n (Session info: chrome=55.0.2883.91)\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64)))”,“status”:33,“value”:{“message”:“session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid ‘context’: {"auxData":{"frameId":"1567.1","isDefault":true},"id":1,"name":"","origin":"://"}\n (Session info: chrome=55.0.2883.91)\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64)”},“httpCode”:200,“origValue”:“A new session could not be created. (Original error: session not created exception\nfrom unknown error: Runtime.executionContextCreated has invalid ‘context’: {"auxData":{"frameId":"1567.1","isDefault":true},"id":1,"name":"","origin":"://"}\n (Session info: chrome=55.0.2883.91)\n (Driver info: chromedriver=2.18.343845 (73dd713ba7fbfb73cbb514e62641d8c96a94682a),platform=Windows NT 6.1 SP1 x86_64))”},“sessionId”:null}
info: ← POST /wd/hub/session 500 17672.848 ms - 1375
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] [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: 15.391
info: [debug] [UIAUTOMATOR STDOUT] OK (1 test)
info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
info: [debug] UiAutomator shut down normally
info: [debug] executing cmd: C:\Users\prasannakumar\AppData\Local\Android\sdk\platform-tools\adb.exe -s 42009062facc1300 shell “am force-stop com.android.chrome”
info: [debug] Stopping logcat capture
info: [debug] Logcat terminated with code null, signal SIGTERM
info: [debug] Cleaning up appium session

i.e…focus on line contains invaid context

from logs seems you haven’t removed the browser caps. Comment below code.
capabilities.setCapability(CapabilityType.BROWSER_NAME, "Android");