Newbie - Calculator app not displaying

Hi, am new to Appium and am trying to load my first app. I have Appium v1.11.1 running and see the calculator app from my phone in the inspector session and have picked up the id for ‘2’ as in the last line of below code. My android phone is connected via usb. ANDROID_HOME and JAVA_HOME are setup correctly.

But I am expecting the calculator to display on my phone and it doesn’t. For that reason I think I get this error on last line of code below. Appium logs are included. Any help would be greatly appreciated.

org.openqa.selenium.NoSuchElementException: An element could not be located on the page using the given search parameters. (WARNING: The server did not provide any stacktrace information

@Test
public void loadingSinglePageTest() throws Exception{
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("deviceName", "Galaxy A5 (2016)");
    capabilities.setCapability("automationName", "Appium");
    capabilities.setCapability("newCommandTimeout", "0");

// capabilities.setCapability(“automationName”, “UiAutomator2”);
// capabilities.setCapability(“automationName”, “uiautomator2”);
capabilities.setCapability(“BROWSER_NAME”, “”);
capabilities.setCapability(“UUID”, “”);

    capabilities.setCapability("appPackage", "/data/app/com.google.android.calculator-1/base.apk");
    capabilities.setCapability("appActivity","com.google.android.calculator");
    capabilities.setCapability("app", "c:\\projects\\Calculator_v7.5 (213680574)_apkpure.com.apk");

    driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities) {
    };
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
    driver.findElement(By.name("2")).click();

Appium logs
The server is running
[Appium] Welcome to Appium v1.11.1
[Appium] Appium REST http interface listener started on 0.0.0.0:4723
[HTTP] --> POST /wd/hub/session
[HTTP] {“desiredCapabilities”:{“appPackage”:"/data/app/com.google.android.calculator-1/base.apk",“appActivity”:“com.google.android.calculator”,“app”:“c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk”,“newCommandTimeout”:“0”,“BROWSER_NAME”:"",“automationName”:“Appium”,“platformName”:“Android”,“UUID”:"",“deviceName”:“Galaxy A5 (2016)”}}
[MJSONWP] Calling AppiumDriver.createSession() with args: [{“appPackage”:"/data/app/com.google.android.calculator-1/base.apk",“appActivity”:“com.google.android.calculator”,“app”:“c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk”,“newCommandTimeout”:“0”,“BROWSER_NAME”:"",“automationName”:“Appium”,“platformName”:“Android”,“UUID”:"",“deviceName”:“Galaxy A5 (2016)”},null,null]
[BaseDriver] Event ‘newSessionRequested’ logged at 1553778061358 (13:01:01 GMT+0000 (GMT Standard Time))
[Appium] DeprecationWarning: ‘automationName’ capability was not provided. Future versions of Appium will require ‘automationName’ capability to be set for Android sessions.
[Appium] Setting automation to ‘UiAutomator1’.
[Appium] Creating new AndroidDriver (v4.8.0) session
[Appium] Capabilities:
[Appium] appPackage: /data/app/com.google.android.calculator-1/base.apk
[Appium] appActivity: com.google.android.calculator
[Appium] app: c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk
[Appium] newCommandTimeout: 0
[Appium] BROWSER_NAME:
[Appium] automationName: Appium
[Appium] platformName: Android
[Appium] UUID:
[Appium] deviceName: Galaxy A5 (2016)
[BaseDriver] Creating session with MJSONWP desired capabilities: {“appPackage”:"/data/app/co…
[BaseDriver] Capability ‘newCommandTimeout’ changed from string (‘0’) to integer (0). This may cause unexpected behavior
[BaseDriver] The following capabilities were provided, but are not recognized by appium: BROWSER_NAME, UUID.
[BaseDriver] Session created with session id: 9642a3f5-8899-4375-bac2-f6fc126dd1c6
[AndroidDriver] Java version is: 1.8.0_201
[ADB] Checking whether adb is present
[ADB] Found 1 ‘build-tools’ folders under ‘C:\android-sdk’ (newest first):
[ADB] C:/android-sdk/build-tools/28.0.3
[ADB] Using adb.exe from C:\android-sdk\platform-tools\adb.exe
[AndroidDriver] Retrieving device list
[ADB] Trying to find a connected android device
[ADB] Getting connected devices…
[ADB] 1 device(s) connected
[AndroidDriver] Using device: 33004097cf83a379
[ADB] Setting device id to 33004097cf83a379
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell getprop ro.build.version.sdk’
[ADB] Current device property ‘ro.build.version.sdk’: 24
[ADB] Device API level: 24
[AndroidDriver] Consider setting ‘automationName’ capability to ‘uiautomator2’ on Android >= 6, since UIAutomator framework is not maintained anymore by the OS vendor.
[BaseDriver] Using local app ‘c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk’
[AndroidDriver] Checking whether app is actually present
[AndroidDriver] Starting Android session
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 wait-for-device’
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell echo ping’
[AndroidDriver] Pushing settings apk to device…
[ADB] Getting install status for io.appium.settings
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell dumpsys package io.appium.settings’
[ADB] ‘io.appium.settings’ is installed
[ADB] Getting package info for ‘io.appium.settings’
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell dumpsys package io.appium.settings’
[ADB] Checking whether aapt is present
[ADB] Using aapt.exe from C:\android-sdk\build-tools\28.0.3\aapt.exe
[ADB] The version name of the installed ‘io.appium.settings’ is greater or equal to the application version name (‘2.14.0’ >= ‘2.14.0’)
[ADB] There is no need to install/upgrade ‘C:\Users\Admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\io.appium.settings\apks\settings_apk-debug.apk’
[ADB] Getting IDs of all ‘io.appium.settings’ processes
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell ‘pgrep --help; echo $?’’
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell pgrep ^appium\.settings$’
[AndroidDriver] io.appium.settings is already running. There is no need to reset its permissions.
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell appops set io.appium.settings android:mock_location allow’
[Logcat] Starting logcat capture
[ADB] Getting device platform version
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell getprop ro.build.version.release’
[ADB] Current device property ‘ro.build.version.release’: 7.0
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell wm size’
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell getprop ro.product.model’
[ADB] Current device property ‘ro.product.model’: SM-A510F
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell getprop ro.product.manufacturer’
[ADB] Current device property ‘ro.product.manufacturer’: samsung
[AndroidDriver] Capability ‘appPackage’ is expected to only include latin letters, digits, underscore, dot, comma and asterisk characters.
[AndroidDriver] Current value ‘/data/app/com.google.android.calculator-1/base.apk’ has non-matching character at index 0: ‘/’
[ADB] Getting install status for /data/app/com.google.android.calculator-1/base.apk
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell dumpsys package /data/app/com.google.android.calculator-1/base.apk’
[ADB] ‘/data/app/com.google.android.calculator-1/base.apk’ is not installed
[ADB] Getting install status for /data/app/com.google.android.calculator-1/base.apk
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell dumpsys package /data/app/com.google.android.calculator-1/base.apk’
[ADB] ‘/data/app/com.google.android.calculator-1/base.apk’ is not installed
[ADB] App ‘c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk’ is not installed
[ADB] Installing ‘c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk’
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 install ‘c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk’’
[ADB] Application ‘c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk’ already installed. Continuing.
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell rm -rf /data/local/tmp/strings.json’
[AndroidDriver] Extracting strings from apk
[AndroidDriver] c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk
[AndroidDriver] undefined
[AndroidDriver] C:\data\app\com.google.android.calculator-1\base.apk
[ADB] Extracting strings from for language: default
[ADB] Successfully extracted 162 strings from ‘c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk’ resources for ‘(default)’ configuration
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 push C:\data\app\com.google.android.calculator-1\base.apk\strings.json /data/local/tmp’
[AndroidBootstrap] Watching for bootstrap disconnect
[ADB] Forwarding system: 4724 to device: 4724
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 forward tcp:4724 tcp:4724’
[UiAutomator] Starting UiAutomator
[UiAutomator] Moving to state ‘starting’
[UiAutomator] Parsing uiautomator jar
[UiAutomator] Found jar name: ‘AppiumBootstrap.jar’
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 push C:\Users\Admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\bootstrap\bin\AppiumBootstrap.jar /data/local/tmp/’
[ADB] Attempting to kill all uiautomator processes
[ADB] Getting IDs of all ‘uiautomator’ processes
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell pgrep ^uiautomator$’
[ADB] No ‘uiautomator’ process has been found
[UiAutomator] Starting UIAutomator
[ADB] Creating ADB subprocess with args: ["-P",5037,"-s",“33004097cf83a379”,“shell”,“uiautomator”,“runtest”,“AppiumBootstrap.jar”,"-c",“io.appium.android.bootstrap.Bootstrap”,"-e",“pkg”,"/data/app/com.google.android.calculator-1/base.apk","-e",“disableAndroidWatchers”,false,"-e",“acceptSslCerts”,false]
[UiAutomator] Moving to state ‘online’
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Loading json…
[AndroidBootstrap] Android bootstrap socket is now connected
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell dumpsys window’
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] json loading complete.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Registered crash watchers.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Client connected
[AndroidDriver] Screen is locked, trying to unlock
[AndroidDriver] Using app unlock, this is going to be deprecated!
[AndroidDriver] Unlocking screen
[AndroidDriver] Launching .Unlock
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell am start -n io.appium.settings/.Unlock -c android.intent.category.LAUNCHER -a android.intent.action.MAIN -f 0x10200000’
[AndroidBootstrap] Emitting alert message…
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell dumpsys window’
[AndroidDriver] Launching .Unlock
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell am start -n io.appium.settings/.Unlock -c android.intent.category.LAUNCHER -a android.intent.action.MAIN -f 0x10200000’
[ADB] Running ‘C:\android-sdk\platform-tools\adb.exe -P 5037 -s 33004097cf83a379 shell am start -W -n /data/app/com.google.android.calculator-1/base.apk/com.google.android.calculator -S’
[Appium] New AndroidDriver session created successfully, session 9642a3f5-8899-4375-bac2-f6fc126dd1c6 added to master session list
[BaseDriver] Event ‘newSessionStarted’ logged at 1553778089204 (13:01:29 GMT+0000 (GMT Standard Time))
[MJSONWP (9642a3f5)] Cached the protocol value ‘MJSONWP’ for the new session 9642a3f5-8899-4375-bac2-f6fc126dd1c6
[MJSONWP (9642a3f5)] Responding to client with driver.createSession() result: {“platform”:“LINUX”,“webStorageEnabled”:false,“takesScreenshot”:true,“javascriptEnabled”:true,“databaseEnabled”:false,“networkConnectionEnabled”:true,“locationContextEnabled”:false,“warnings”:{},“desired”:{“appPackage”:"/data/app/com.google.android.calculator-1/base.apk",“appActivity”:“com.google.android.calculator”,“app”:“c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk”,“newCommandTimeout”:0,“BROWSER_NAME”:"",“automationName”:“Appium”,“platformName”:“Android”,“UUID”:"",“deviceName”:“Galaxy A5 (2016)”},“appPackage”:"/data/app/com.google.android.calculator-1/base.apk",“appActivity”:“com.google.android.calculator”,“app”:“c:\projects\Calculator_v7.5 (213680574)_apkpure.com.apk”,“newCommandTimeout”:0,“BROWSER_NAME”:"",“automationName”:“Appium”,“platformName”:“Android”,“UUID”:"",“deviceName”:“33004097cf83a379”,“deviceUDID”:“33004097cf83a379”,“platformVersion”:“7.0”,“deviceScreenSize”:“1080x1920”,“deviceModel”:“SM-A510F”,“deviceManufacturer”:“samsung”}
[HTTP] <-- POST /wd/hub/session 200 27858 ms - 1044
[HTTP]
[HTTP] --> POST /wd/hub/session/9642a3f5-8899-4375-bac2-f6fc126dd1c6/timeouts/implicit_wait
[HTTP] {“ms”:20000}
[MJSONWP (9642a3f5)] Calling AppiumDriver.implicitWait() with args: [20000,“9642a3f5-8899-4375-bac2-f6fc126dd1c6”]
[BaseDriver] Set implicit wait to 20000ms
[MJSONWP (9642a3f5)] Responding to client with driver.implicitWait() result: null
[HTTP] <-- POST /wd/hub/session/9642a3f5-8899-4375-bac2-f6fc126dd1c6/timeouts/implicit_wait 200 5 ms - 76
[HTTP]
[HTTP] --> POST /wd/hub/session/9642a3f5-8899-4375-bac2-f6fc126dd1c6/element
[HTTP] {“using”:“id”,“value”:“com.google.android.calculator:id/digit_2”}
[MJSONWP (9642a3f5)] Calling AppiumDriver.findElement() with args: [“id”,“com.google.android.calculator:id/digit_2”,“9642a3f5-8899-4375-bac2-f6fc126dd1c6”]
[BaseDriver] Valid locator strategies for this request: xpath, id, class name, accessibility id, -android uiautomator
[BaseDriver] Waiting up to 20000 ms for condition
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 832 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 2126 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 3395 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 4763 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 5985 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 7236 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 9005 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 10246 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 11500 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 12666 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 14331 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 15587 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 16878 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 18098 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[BaseDriver] Waited for 19360 ms so far
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:{“strategy”:“id”,“selector”:“com.google.android.calculator:id/digit_2”,“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Returning result: {“status”:7,“value”:“No element found”}
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Matched JSONWP error code 7 to NoSuchElementError
[MJSONWP (9642a3f5)] Encountered internal error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
[MJSONWP (9642a3f5)] at AndroidDriver.helpers.findElOrEls (C:\Users\Admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
[MJSONWP (9642a3f5)] at process._tickCallback (internal/process/next_tick.js:68:7)
[HTTP] <-- POST /wd/hub/session/9642a3f5-8899-4375-bac2-f6fc126dd1c6/element 500 20536 ms - 164
[HTTP]

Can you try:
WebElement 2 = driver.findElement(By.name(“2”);
2.click();

Hi, I think my problem is that the calculator isn’t displaying so no locator is going to work. I tried your suggestion “By.name” to begin with but got “Locator Strategy ‘name’ is not supported for this session” so instead I used “By.id”. Thanks.

After some research have changed setCapability to be MobileCapabilityType but am still not getting the app to display on the screen (which I assume is what should be happening?)
Am getting same error
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘com.google.android.calculator:id/digit_2’ using ‘ID’ with the contextId: ‘’ multiple: false
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using: UiSelector[INSTANCE=0, RESOURCE_ID=com.google.android.calculator:id/digit_2]
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Failed to locate element. Clearing Accessibility cache and retrying.

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Galaxy A5 (2016)");
    capabilities.setCapability(MobileCapabilityType.VERSION, "5.1.1");

    capabilities.setCapability("appPackage", "/data/app/com.google.android.calculator-1/base.apk");
    capabilities.setCapability("appActivity","com.google.android.calculator");
    capabilities.setCapability("app", "c:\\projects\\Calculator_v7.5 (213680574)_apkpure.com.apk");

    driver = new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

// WebElement txt = driver.findElement(By.name(“2”));
// txt.click();
driver.findElement(By.id(“com.google.android.calculator:id/digit_2”)).click();

When you start your tests does the calculator app get brought to the front? Perhaps you need to specify a device_ID. You can find this through the command: ADB devices

Thanks for help Tom. Have added device_ID now but still not displaying. Have managed to get google.com displaying when in browser mode, which is good. But shame my app won’t display!

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability(MobileCapabilityType.PLATFORM, Platform.ANDROID);
    capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
    capabilities.setCapability(MobileCapabilityType.DEVICE_NAME,"Galaxy A5 (2016)");
    capabilities.setCapability(MobileCapabilityType.VERSION, "5.1.1");
    capabilities.setCapability("automationName", "UiAutomator1");
    capabilities.setCapability("device_ID", "33004097cf83a379");

    capabilities.setCapability("appPackage", "/data/app/com.google.android.calculator-1/base.apk");
    capabilities.setCapability("appActivity","com.google.android.calculator");
    capabilities.setCapability("app", "c:\\projects\\Calculator_v7.5 (213680574)_apkpure.com.apk");

    URL url = new URL("http://127.0.0.1:4723/wd/hub");
    driver = new AndroidDriver(url, capabilities);

// driver.get(“http://www.google.com”);

    driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

// WebElement txt = driver.findElement(By.name(“2”));
// txt.click();
driver.findElement(By.id(“com.google.android.calculator:id/digit_2”)).click();

Are you sure that your appPackage and appActivity capabilities are correct?
Launch your app and then start ADB shell
and execute this command to check for appPackage and appActivity values
“dumpsys window windows | grep -E ‘mCurrentFocus’”

adb shell dumpsys window windows | grep mCurrentFocus
returned “mCurrentFocus=Window{7e2b422d0 u0 com.google.android.calculator/com.android.calculator2.Calculator}”
which made be realise I had appActivity and appPackage the wrong way around.
Also, the contents of appActivity needed changing from “/data/app/com.google.android.calculator-1/base.apk” to “com.android.calculator2.Calculator” Many thanks.