java.lang.NoSuchFieldError: INSTANCE Exception While Running Appium Android Test

I’m working with an Appium Android Test. I didn’t have any problems with my test and it was working well. After few weeks, I tried to run it again (without any changes) and now I get the following error:


Caused by: java.lang.NoSuchFieldError: INSTANCE
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.(SSLConnectionSocketFactory.java:144)
at org.openqa.selenium.remote.internal.HttpClientFactory.getClientConnectionManager(HttpClientFactory.java:71)
at org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:57)
at org.openqa.selenium.remote.internal.HttpClientFactory.(HttpClientFactory.java:60)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.getDefaultHttpClientFactory(ApacheHttpClient.java:251)
at org.openqa.selenium.remote.internal.ApacheHttpClient$Factory.(ApacheHttpClient.java:228)
at org.openqa.selenium.remote.HttpCommandExecutor.getDefaultClientFactory(HttpCommandExecutor.java:96)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:70)
at org.openqa.selenium.remote.HttpCommandExecutor.(HttpCommandExecutor.java:58)
at org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:156)
at io.appium.java_client.DefaultGenericMobileDriver.(DefaultGenericMobileDriver.java:22)
at io.appium.java_client.AppiumDriver.(AppiumDriver.java:202)
at io.appium.java_client.android.AndroidDriver.(AndroidDriver.java:50)
at web.mobile.test.Keywords.openApp(Keywords.java:207)
… 7 more

he problem is located on the command driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);. Can anyone please tell me why this is happening?


Currently i using Keyword driven framework using Gradle
/ Apply the java plugin to add support for Java
apply plugin: ‘java’
apply plugin: ‘eclipse’
apply plugin: ‘maven’
apply plugin: ‘application’

mainClassName = ‘main.Intial’

repositories {
// Use ‘jcenter’ for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
flatDir {
dirs ‘libs’
}
//jcenter()
mavenCentral()
mavenLocal()

}
dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile "com.relevantcodes:extentreports:2.40.2"
  //compile 'org.xerial:sqlite-jdbc:3.8.11.1'
  compile 'org.testng:testng:6.8.5'
  compile  'commons-codec:commons-codec:1.9'
  compile  'net.sourceforge.nekohtml:nekohtml:1.9.22'
  //compile 'org.eclipse.jetty:jetty-websocket:8.1.8.v20121106'
  compile 'net.java.dev.jna:jna:4.2.0'
  compile 'dom4j:dom4j:1.6.1'
  compile 'xml-apis:xml-apis:1.4.01'
  compile 'commons-logging:commons-logging:1.1.3'
  compile 'io.netty:netty:3.5.7.Final'
  compile 'org.apache.poi:poi:3.7'
  compile 'org.apache.poi:poi-ooxml:3.9'
  compile 'io.appium:java-client:3.3.0'
  compile 'io.appium:java-client:2.1.0'
  compile 'javax.mail:mail:1.4'
  compile 'javax.mail:javax.mail-api:1.5.1'
  compile 'com.jayway.android.robotium:robotium-solo:4.3.1'
  compile 'log4j:log4j:1.2.17'
  //compile 'org.freemarker:freemarker:2.3.23'
  //Local maven
  compile 'com.extentm.extentmerge:ContentHub:2.0'
  compile 'org.apache.httpcomponents:httpclient:4.3.6'
  compile  'org.apache.httpcomponents:httpmime:4.3.6'
  //compile 'org.apache.httpcomponents:httpcore:4.4.4'
  //compile 'org.apache.httpcomponents:httpclient:4.5.1'
  //compile 'org.apache.httpcomponents:httpmime:4.5.1'
  //compile 'org.apache.httpcomponents:httpcore:4.4.4'
  //exclude ':httpclient'
  //exclude module: 'httpmime'

}

jar {
baseName = ‘gs-gradle’
version = ‘0.1.0’
}
task wrapper(type: Wrapper) {
gradleVersion = ‘2.3’
}


function which using to initialize capabilities :
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(“platformName”, “Android”);
capabilities.setCapability(“deviceName”, “XXX”);
capabilities.setCapability(“platformVersion”, “5.0.1”);
capabilities.setCapability(“appPackage”, “<app_package>”);
capabilities.setCapability(“appActivity”, “<app_activity>”);
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Hi

anyone got above error message. Plz help me to resolve the same

It seems it has nothing to do with appium but with your dependencies.

Its late response but will help to others in future.
As @Telmo_Cardoso said, its issue with dependencies.
Please remove duplicate dependencies.(i.e. use only one version of dependency, don’t keep multiple versions of same dependency).