0

I am new to learn Java+Appium. Getting below error. Please help me to understand how to solve this issue. Is there any jar file missing ?

Sharing code as well for better understanding.

Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/ConnectionPool
    at org.openqa.selenium.remote.internal.OkHttpClient$Factory.<init>(OkHttpClient.java:116)
    at org.openqa.selenium.remote.http.HttpClient$Factory.createDefault(HttpClient.java:66)
    at org.openqa.selenium.remote.HttpCommandExecutor.<clinit>(HttpCommandExecutor.java:47)
    at io.appium.java_client.AppiumDriver.<init>(AppiumDriver.java:97)
    at io.appium.java_client.android.AndroidDriver.<init>(AndroidDriver.java:94)
    at secondAppium.main(secondAppium.java:30)
Caused by: java.lang.ClassNotFoundException: okhttp3.ConnectionPool
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 6 more

/CODE/

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.remote.DesiredCapabilities;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.remote.MobileCapabilityType;

public class secondAppium {

    public static <AppiumWebElement> void main(String[] args) throws MalformedURLException {
        // TODO Auto-generated method stub

        File f = new File("src");
        //File f = new File("C:/Users/HP/eclipse-workspace/AppiumProject/src/secondAppium.java");
        File fs = new File(f,"ApiDemos-debug.apk");

        DesiredCapabilities dc = new DesiredCapabilities();
        dc.setCapability(MobileCapabilityType.DEVICE_NAME, "ShaziaEmulator");
        dc.setCapability(MobileCapabilityType.APP, fs.getAbsolutePath());
        //MutableCapabilities capabilities = null;
        dc.setCapability(MobileCapabilityType.AUTOMATION_NAME,"uiautomator2"); 
        AndroidDriver driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),dc);   
    }
}
tester
  • 1
  • 3
  • Does this address the question? https://stackoverflow.com/questions/49404956/exception-in-thread-main-java-lang-noclassdeffounderror-okhttp3-connectionpoo If you're not already using one, I'd recommend you migrate to a dependency management system such as Maven or Gradle. With the sheer number of dependencies (and dependencies of dependencies) a single project may have, including each Jar manually can become a nightmare. – Christopher Schneider Jan 22 '20 at 18:28

0 Answers0