mobile automation – Appium – Could not find ‘apksigner.jar’

Error:

 Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of 'C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.17.4.apk'. Original error: Could not find 'apksigner.jar' in ["C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\platform-tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\emulator\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\cmdline-tools\latest\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\apksigner.jar"]. Do you have Android Build Tools installed at 'C:UsersadminDownloadscommandlinetools-win-6858069_latestcmdline-toolsbinpath-to-where-cmdline-tools-is'?
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-LBV2D64', ip: '192.168.6.108', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of 'C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.17.4.apk'. Original error: Could not find 'apksigner.jar' in ["C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\platform-tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\emulator\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\cmdline-tools\latest\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\apksigner.jar"]. Do you have Android Build Tools installed at 'C:UsersadminDownloadscommandlinetools-win-6858069_latestcmdline-toolsbinpath-to-where-cmdline-tools-is'?
    at getResponseForW3CError (C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolerrors.js:804:9)
    at asyncHandler (C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolprotocol.js:380:37)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-LBV2D64', ip: '192.168.6.108', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: driver.version: AndroidDriver
    at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:216)
    at io.appium.java_client.remote.AppiumCommandExecutor.createSession(AppiumCommandExecutor.java:225)
    at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:247)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:41)
    at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
    at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
    at io.appium.java_client.AppiumDriver.startSession(AppiumDriver.java:338)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at io.appium.java_client.DefaultGenericMobileDriver.<init>(DefaultGenericMobileDriver.java:37)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:89)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:99)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:96)
    at appiumTest.CalculatorOpenTest.main(CalculatorOpenTest.java:33)
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at io.appium.java_client.remote.AppiumCommandExecutor$1.createSession(AppiumCommandExecutor.java:193)
    ... 14 more
Caused by: org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of 'C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.17.4.apk'. Original error: Could not find 'apksigner.jar' in ["C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\platform-tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\emulator\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\cmdline-tools\latest\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\apksigner.jar"]. Do you have Android Build Tools installed at 'C:UsersadminDownloadscommandlinetools-win-6858069_latestcmdline-toolsbinpath-to-where-cmdline-tools-is'?
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-LBV2D64', ip: '192.168.6.108', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
Driver info: driver.version: AndroidDriver
remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: Cannot verify the signature of 'C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-uiautomator2-serverapksappium-uiautomator2-server-v4.17.4.apk'. Original error: Could not find 'apksigner.jar' in ["C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\platform-tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\emulator\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\cmdline-tools\latest\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\tools\bin\apksigner.jar","C:\Users\admin\Downloads\commandlinetools-win-6858069_latest\cmdline-tools\bin\path-to-where-cmdline-tools-is\apksigner.jar"]. Do you have Android Build Tools installed at 'C:UsersadminDownloadscommandlinetools-win-6858069_latestcmdline-toolsbinpath-to-where-cmdline-tools-is'?
    at getResponseForW3CError (C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolerrors.js:804:9)
    at asyncHandler (C:UsersadminAppDataRoamingnpmnode_modulesappiumnode_modulesappium-base-driverlibprotocolprotocol.js:380:37)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
    at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:543)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
    ... 19 more

My code:

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;

//import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class CalculatorOpenTest {

    static AndroidDriver<WebElement> driver;
    
    public static void main(String[] args) throws Throwable 
    {
        DesiredCapabilities cap= new DesiredCapabilities();
        cap.setCapability(MobileCapabilityType.AUTOMATION_NAME,"UiAutomator2");
        //cap.setCapability("automationName", "UiAutomator2");
        //cap.setCapability("automationName", "UiAutomator1");
        cap.setCapability(MobileCapabilityType.DEVICE_NAME,"Roy Galaxy M51");
        cap.setCapability(MobileCapabilityType.UDID, "RZ8N91NX7WF");
        cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
        cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "11");
        
        cap.setCapability("appPackage", "com.google.android.calculator");
        cap.setCapability("appActivity", "com.android.calculator2.calculator");
        
        URL url= new URL("http://localhost:4723/wd/hub");
        driver= new AndroidDriver<WebElement>(url,cap);
        System.out.println("Application Started Successfully....");
    

    }
    
}

Leave a Comment