When I used the 3.5.0 version of okhttp, I encountered a weird exception
Exception in thread "main" java.lang.NoClassDefFoundError: okio/BufferedSource
at okhttp3.internal.Util.
at okhttp3.OkHttpClient.
at com.demo.okHttp.Demo.main(Demo.java:8)
Caused by: java.lang.ClassNotFoundException: okio.BufferedSource
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
however, when I use the 3.2 it works fine. My code is as simple as
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
}
and I have okhttp 3.5.0 and okio 1.11.0 imported to my project. Is this a bug in the 3.5.0 version, how can I solve this problem?
Your Okio import didn't work or this exception wouldn't occur. Are you sure
you've done it correctly?
On Mon, Dec 26, 2016, 9:25 PM runyan notifications@github.com wrote:
When I used the 3.5.0 version of okhttp, I encountered a weird exception
Exception in thread "main" java.lang.NoClassDefFoundError:
okio/BufferedSource
at okhttp3.internal.Util.(Util.java:48)
at okhttp3.OkHttpClient.(OkHttpClient.java:121)
at com.demo.okHttp.Demo.main(Demo.java:8)
Caused by: java.lang.ClassNotFoundException: okio.BufferedSource
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
however, when I use the 3.2 it works fine. My code is as simple as
public static void main(String[] args) { OkHttpClient client = new
OkHttpClient(); }
and I have okhttp 3.5.0 and okio 1.11.0 imported to my project. Is this a
bug in the 3.5.0 version, how can I solve this problem?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/okhttp/issues/3065, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEEEcyjhPsFu3yFgeOMKr6MDHk1bQkcks5rMHcLgaJpZM4LV--p
.
@JakeWharton I used maven to build my project, here is my current dependencies
@JakeWharton
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.5.0</version>
</dependency>
Sadly there's nothing we can do here. Something in your tool chain is not pulling in the Okio dependency.
hey, guys .. well the solution suggested by @JakeWharton worked for me in Java. I am using the jar as opposed to what @JakeWharton suggested ,
you need also download the okio.jar as your project module
I had to include these in my org.apache.maven.plugins like so:
```
....
....
Most helpful comment
you need also download the okio.jar as your project module