Skip to content

Getting No Such Field Error while initializing Android Driver #1635

@prabhurohith

Description

@prabhurohith

Description

Trying with Appium 2.0 client and not able to create the session.Running using cucumber and below is the client code for the same.

Capability Builder Code

  switch (deviceInfo.getDeviceOS().toUpperCase()) {
            case "ANDROID":
                desiredOptns = new UiAutomator2Options()
                        .setDeviceName(deviceInfo.getDeviceName())
                        .setNewCommandTimeout(Duration.ofSeconds(70))
                        .setApp(System.getProperty("user.dir") + "/TestData/Apps/" + envName + "/" + appName + ".apk")
                        .eventTimings()
                        .setSystemPort(8200 + Integer.parseInt(deviceInfo.getDeviceNo()));

Hook Steps / Invoker Code

    
        try {
            service = new AppiumServiceBuilder()
                    .withIPAddress("127.0.0.1")
                    .usingAnyFreePort()
                    .withTimeout(Duration.ofSeconds(300))
                    .build();
            service.start();
            if (platformName.equalsIgnoreCase("device")) {
                CommonValues browserType = null;
                AppiumServerDetails appiumServer = new RunnerUtils().getServerDetails("server" + deviceInfo.getDeviceNo());
                switch (deviceInfo.getDeviceOS().toUpperCase()) {
                    case "IOS":
                        deviceDriver = new IOSDriver(new URL("http://127.0.0.1:4723"), desiredCapOptions);
                        break;
                    case "ANDROID":
                        String url = "http://" + appiumServer.getIpAddress() + ":" + appiumServer.getStartPortAdd() + "/wd/hub";
                        deviceDriver = new AndroidDriver(service.getUrl(), desiredCapOptions);
                        break;
                }
            }
        }

Environment

  • Java client build version or git revision if you use some snapshot: java version "1.8.0_261"
  • Appium server version or git revision if you use some snapshot: 2.0.0-beta.24
  • Desktop OS/version used to run Appium if necessary: Windows 10
  • Node.js version (unless using Appium.app|exe) or Appium CLI or Appium.app|exe: 7.21.0
  • Mobile platform/version under test:
  • Real device or emulator/simulator: Android Emulator
  • Appium Client : 8.0.0-bet
    AppiumErrorFor_2_0.txt

Details

While trying to debug the exception was on AppiumDriver.class method shared below

protected static Capabilities ensureAutomationName(Capabilities originalCapabilities, String defaultName) {
    String currentAutomationName = (String)CapabilityHelpers.getCapability(originalCapabilities, "automationName", String.class);
    if (StringUtils.isBlank(currentAutomationName)) {
        **String capabilityName = originalCapabilities.getCapabilityNames().contains("automationName") ? "automationName" : "appium:automationName";**
        return originalCapabilities.merge(new ImmutableCapabilities(capabilityName, defaultName));
    } else {
        return originalCapabilities;
    }
}

Code To Reproduce Issue [ Good To Have ]

Using Cucumber feature file to invoke the tests.

Exception Stacktraces

Step failed
java.lang.NoSuchFieldError: PERMANENT_REDIRECT
at org.asynchttpclient.util.HttpConstants$ResponseStatusCodes.(HttpConstants.java:47)
at org.asynchttpclient.netty.handler.intercept.Redirect30xInterceptor.(Redirect30xInterceptor.java:54)
at org.asynchttpclient.netty.handler.intercept.Interceptors.(Interceptors.java:52)
at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.(AsyncHttpClientHandler.java:59)
at org.asynchttpclient.netty.handler.HttpHandler.(HttpHandler.java:39)
at org.asynchttpclient.netty.channel.ChannelManager.configureBootstraps(ChannelManager.java:212)
at org.asynchttpclient.DefaultAsyncHttpClient.(DefaultAsyncHttpClient.java:94)
at org.asynchttpclient.Dsl.asyncHttpClient(Dsl.java:32)
at org.openqa.selenium.remote.http.netty.NettyClient.createHttpClient(NettyClient.java:103)
at org.openqa.selenium.remote.http.netty.NettyClient.(NettyClient.java:50)
at org.openqa.selenium.remote.http.netty.NettyClient$Factory.createClient(NettyClient.java:144)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:107)
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:66)
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:82)
at io.appium.java_client.remote.AppiumCommandExecutor.(AppiumCommandExecutor.java:87)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:87)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:116)
at com.device.app.stepdefinitions.HookSteps.configureTheDriver(HookSteps.java:113)

Link To Appium Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions