I try to use Okhttp and Scarlet library but when I run project this exception throws. how can I fix it? I search about it and I found out that the version of https is not the same in different library I added to my maven.in my maven dependency i see okhttp-4.9.1.jar and I do NOT know how i can change the version of that. please help me ...
Exception in thread "main" java.lang.NoSuchFieldError: Companion
at okhttp3.internal.Util.<clinit>(Util.kt:71)
at okhttp3.OkHttpClient.<clinit>(OkHttpClient.kt:1073)
at crypto.Main.main(Main.java:16)
my pom.xml file :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cripto</groupId>
<artifactId>crypto</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.tinder.scarlet</groupId>
<artifactId>websocket-okhttp</artifactId>
<version>0.1.12</version>
</dependency>
<dependency>
<groupId>com.tinder.scarlet</groupId>
<artifactId>scarlet</artifactId>
<version>0.1.12</version>
</dependency>
<dependency>
<groupId>com.tinder.scarlet</groupId>
<artifactId>message-adapter-gson</artifactId>
<version>0.1.12</version>
</dependency>
</dependencies>
</project>
public static String Url = "wss://stream.binance.com:9443" ;
public static void main(String[] args) {
// TODO Auto-generated method stub
OkHttpClient client = new OkHttpClient() ;
System.out.println(client) ;
Scarlet scarlet = new Scarlet.Builder()
.webSocketFactory(OkHttpClientUtils.newWebSocketFactory(client,Url))
.addMessageAdapterFactory(new GsonMessageAdapter.Factory())
//.addStreamAdapterFactory(new RxJava2StreamAdapterFactory())
.build() ;
}