Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl
justin-fiedler opened this issue · 1 comments
justin-fiedler commented
Expected Behavior
Amplitude should work on Android API 30.
Current Behavior
W/xample.ampliap: Accessing hidden method Lcom/android/org/conscrypt/OpenSSLSocketImpl;->setUseSessionTickets(Z)V (greylist-max-q,core-platform-api, reflection, denied)
W/OkHttp: unable to load android socket classes
W/OkHttp: java.lang.NoSuchMethodException: com.android.org.conscrypt.OpenSSLSocketImpl.setUseSessionTickets [boolean]
W/OkHttp: at java.lang.Class.getMethod(Class.java:2072)
W/OkHttp: at java.lang.Class.getDeclaredMethod(Class.java:2050)
W/OkHttp: at okhttp3.internal.platform.android.AndroidSocketAdapter.<init>(AndroidSocketAdapter.kt:34)
W/OkHttp: at okhttp3.internal.platform.android.StandardAndroidSocketAdapter.<init>(StandardAndroidSocketAdapter.kt:31)
W/OkHttp: at okhttp3.internal.platform.android.StandardAndroidSocketAdapter$Companion.buildIfSupported(StandardAndroidSocketAdapter.kt:57)
W/OkHttp: at okhttp3.internal.platform.android.StandardAndroidSocketAdapter$Companion.buildIfSupported$default(StandardAndroidSocketAdapter.kt:50)
W/OkHttp: at okhttp3.internal.platform.AndroidPlatform.<init>(AndroidPlatform.kt:44)
W/OkHttp: at okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported(AndroidPlatform.kt:239)
W/OkHttp: at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:211)
W/OkHttp: at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:179)
W/OkHttp: at okhttp3.internal.platform.Platform.<clinit>(Platform.kt:180)
W/OkHttp: at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:219)
W/OkHttp: at okhttp3.OkHttpClient.<init>(OkHttpClient.kt:211)
W/OkHttp: at com.amplitude.api.AmplitudeClient.$r8$lambda$uWBdBgn9ebx5ZjaSsGzJj44YwX4(Unknown Source:2)
W/OkHttp: at com.amplitude.api.AmplitudeClient$$ExternalSyntheticLambda0.get(Unknown Source:0)
W/OkHttp: at com.amplitude.util.DoubleCheck.get(DoubleCheck.java:28)
W/OkHttp: at com.amplitude.api.AmplitudeClient.lambda$null$0(AmplitudeClient.java:347)
W/OkHttp: at com.amplitude.api.AmplitudeClient$$ExternalSyntheticLambda2.newCall(Unknown Source:2)
W/OkHttp: at com.amplitude.api.AmplitudeClient.makeEventUploadPostRequest(AmplitudeClient.java:2113)
W/OkHttp: at com.amplitude.api.AmplitudeClient$12.run(AmplitudeClient.java:1978)
W/OkHttp: at android.os.Handler.handleCallback(Handler.java:938)
W/OkHttp: at android.os.Handler.dispatchMessage(Handler.java:99)
W/OkHttp: at android.os.Looper.loop(Looper.java:223)
W/OkHttp: at android.os.HandlerThread.run(HandlerThread.java:67)
Solution
Update to latest OkHttp
dependencies {
implementation 'com.amplitude:android-sdk:2.34.1'
implementation 'com.squareup.okhttp3:okhttp:4.9.3'
}
Steps to Reproduce
Use the dependencies from Amplitude documentation
dependencies {
implementation 'com.amplitude:android-sdk:2.34.1'
implementation 'com.squareup.okhttp3:okhttp:4.2.2'
}
amplitude.logEvent("My Event")
Environment
- SDK Version: 2.34.1
- Android API Level: 30
- Device: Emulator
justin-fiedler commented
OkHttp uses reflection to access sockets and is strongly coupled with the version of Android.
Solution above works for API 30. Depending on your API version you may need to switch to other OkHttp versions, including downgrading for older API versions as described here: https://developers.amplitude.com/docs/unity#6-android-api-compatibility