Reputation: 161
So I'm running into an issue integrating SendBird into an existing Android application. The existing application uses React Native for it's front end and I'm implementing SendBird into the native Android side. I've followed the tutorial and have an example app running just fine. However at run time, I'm running into issues with OkHttp
The issue arises AFTER I call the init for SenBird's UIKit
SendbirdUIKit.init(new SendbirdUIKitAdapter())
Once I call this code the issue happens. If I attempt to call an API using Retrofit I get the following crash
FATAL EXCEPTION: OkHttp Dispatcher
Process: com.***, PID: 17631
java.lang.ExceptionInInitializerError
at okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion$factory$1.matchesSocket(ConscryptSocketAdapter.kt:58)
at okhttp3.internal.platform.android.DeferredSocketAdapter.matchesSocket(DeferredSocketAdapter.kt:37)
at okhttp3.internal.platform.Android10Platform.configureTlsExtensions(Android10Platform.kt:51)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:375)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.***.APIHandler.lambda$get7BossClient$0(APIHandler.java:51)
at com.***.APIHandler$$ExternalSyntheticLambda0.intercept(Unknown Source:2)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.conscrypt.Conscrypt$Version.major()' on a null object reference
at okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(ConscryptPlatform.kt:129)
at okhttp3.internal.platform.ConscryptPlatform.<clinit>(ConscryptPlatform.kt:115)
at okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion$factory$1.matchesSocket(ConscryptSocketAdapter.kt:58)
at okhttp3.internal.platform.android.DeferredSocketAdapter.matchesSocket(DeferredSocketAdapter.kt:37)
at okhttp3.internal.platform.Android10Platform.configureTlsExtensions(Android10Platform.kt:51)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:375)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.***.APIHandler.lambda$get7BossClient$0(APIHandler.java:51)
at com.***.APIHandler$$ExternalSyntheticLambda0.intercept(Unknown Source:2)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
And if I try to launch an Activity of SendBird's like the ChannelListActivity I get the following error
FATAL EXCEPTION: OkHttp Dispatcher
Process: com.seveneleven.rnd.tabasco.ris2, PID: 16711
java.lang.ExceptionInInitializerError
at com.sendbird.android.shadow.okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion$factory$1.matchesSocket(ConscryptSocketAdapter.kt:58)
at com.sendbird.android.shadow.okhttp3.internal.platform.android.DeferredSocketAdapter.matchesSocket(DeferredSocketAdapter.kt:37)
at com.sendbird.android.shadow.okhttp3.internal.platform.Android10Platform.configureTlsExtensions(Android10Platform.kt:51)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:375)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
at com.sendbird.android.shadow.okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at com.sendbird.android.shadow.okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at com.sendbird.android.shadow.okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at com.sendbird.android.shadow.okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int org.conscrypt.Conscrypt$Version.major()' on a null object reference
at com.sendbird.android.shadow.okhttp3.internal.platform.ConscryptPlatform$Companion.atLeastVersion(ConscryptPlatform.kt:129)
at com.sendbird.android.shadow.okhttp3.internal.platform.ConscryptPlatform.<clinit>(ConscryptPlatform.kt:115)
at com.sendbird.android.shadow.okhttp3.internal.platform.android.ConscryptSocketAdapter$Companion$factory$1.matchesSocket(ConscryptSocketAdapter.kt:58)
at com.sendbird.android.shadow.okhttp3.internal.platform.android.DeferredSocketAdapter.matchesSocket(DeferredSocketAdapter.kt:37)
at com.sendbird.android.shadow.okhttp3.internal.platform.Android10Platform.configureTlsExtensions(Android10Platform.kt:51)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealConnection.connectTls(RealConnection.kt:375)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.kt:337)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealConnection.connect(RealConnection.kt:209)
at com.sendbird.android.shadow.okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:226)
at com.sendbird.android.shadow.okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
at com.sendbird.android.shadow.okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
at com.sendbird.android.shadow.okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
at com.sendbird.android.shadow.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
at com.sendbird.android.shadow.okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:920)
It looks like SendBird's UIKit has it's own OkHttp3 implementation that is overriding the library I have locally. Below is what I have listed in my gradle
implementation('com.squareup.retrofit2:retrofit:2.9.0') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation('com.squareup.retrofit2:converter-gson:2.9.0') {
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
}
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.11.0'
implementation group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '4.10.0'
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.2")
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.11.0'
implementation group: 'com.squareup.okhttp3', name: 'logging-interceptor', version: '4.10.0'
implementation("com.squareup.okhttp3:okhttp-urlconnection:4.9.2")```
Upvotes: 1
Views: 78