Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue crash on kitkat 4.4 #259

Open
kadaluarsa opened this issue Dec 31, 2020 · 8 comments
Open

issue crash on kitkat 4.4 #259

kadaluarsa opened this issue Dec 31, 2020 · 8 comments
Labels
bug Something isn't working

Comments

@kadaluarsa
Copy link

kadaluarsa commented Dec 31, 2020

Expected Behavior

not crash and work normally like others sdk

Current Behavior

i got crash report from google console vitals here is the stacktrace
java.lang.ExceptionInInitializerError:
at okhttp3.internal.platform.Platform$Companion.findAndroidPlatform (Platform.java:219)
at okhttp3.internal.platform.Platform$Companion.findPlatform (Platform.java:212)
at okhttp3.internal.platform.Platform$Companion.access$findPlatform (Platform.java:169)
at okhttp3.internal.platform.Platform. (Platform.java:170)
at okhttp3.OkHttpClient. (OkHttpClient.java:237)
at okhttp3.OkHttpClient. (OkHttpClient.java:222)
at com.amplitude.api.AmplitudeClient$1.run (AmplitudeClient.java:266)
at android.os.Handler.handleCallback (Handler.java:733)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:146)
at android.os.HandlerThread.run (HandlerThread.java:61)
Caused by: java.lang.IllegalStateException:
at okhttp3.internal.platform.AndroidPlatform. (AndroidPlatform.java:153)
at okhttp3.internal.platform.Platform$Companion.findAndroidPlatform (Platform.java:219)
at okhttp3.internal.platform.Platform$Companion.findPlatform (Platform.java:212)
at okhttp3.internal.platform.Platform$Companion.access$findPlatform (Platform.java:169)
at okhttp3.internal.platform.Platform. (Platform.java:170)
at okhttp3.OkHttpClient. (OkHttpClient.java:237)
at okhttp3.OkHttpClient. (OkHttpClient.java:222)
at com.amplitude.api.AmplitudeClient$1.run (AmplitudeClient.java:266)
at android.os.Handler.handleCallback (Handler.java:733)
at android.os.Handler.dispatchMessage (Handler.java:95)
at android.os.Looper.loop (Looper.java:146)
at android.os.HandlerThread.run (HandlerThread.java:61)

Possible Solutionu

I have no idea why this error happens because on SDK above 19 it works normally.

Steps to Reproduce

Environment

  • SDK Version: 10.0.02
  • Android API Level: SDK 19 kitkat
  • Device: All device with SDK 19
@kadaluarsa kadaluarsa added the bug Something isn't working label Dec 31, 2020
@haoliu-amp
Copy link
Contributor

Have you set up okhttp dependency? https://developers.amplitude.com/docs/android#1-add-dependencies

@kadaluarsa
Copy link
Author

kadaluarsa commented Jan 13, 2021

Have you set up okhttp dependency? https://developers.amplitude.com/docs/android#1-add-dependencies

yes okhttp has been set but the problem still exist

@pfay-fc
Copy link

pfay-fc commented Dec 2, 2021

I see the same (or very very similar) on KitKat (4.4.4 and 4.4.2 primarily). I'm integrated through Unity, I haven't explicitly downgraded okhttp as required for kitkat, sounds like I could fix it via https://developers.amplitude.com/docs/unity#6-android-api-compatibility

java.lang.ExceptionInInitializerError

Platform.kt:211 okhttp3.internal.platform.Platform$Companion.findPlatform	
Platform.kt:179 okhttp3.internal.platform.Platform$Companion.access$findPlatform	
Platform.kt:180 okhttp3.internal.platform.Platform.<clinit>	
OkHttpClient.kt:219 okhttp3.OkHttpClient.<init>	
OkHttpClient.kt:211 okhttp3.OkHttpClient.<init>	
lambda:-1 com.amplitude.api.-$$Lambda$iEmU3psnaPI6bh5_pSglQ7pSGnc.get	
DoubleCheck.java:28 com.amplitude.util.DoubleCheck.get	
AmplitudeClient.java:347 com.amplitude.api.AmplitudeClient.lambda$null$0	
lambda:-1 com.amplitude.api.-$$Lambda$AmplitudeClient$fA9cZprCGw0DAi-FOkvviXMs1Sw.newCall	
AmplitudeClient.java:2081 com.amplitude.api.AmplitudeClient.makeEventUploadPostRequest	
AmplitudeClient.java:1946 com.amplitude.api.AmplitudeClient$12.run	
Handler.java:733 android.os.Handler.handleCallback	
Handler.java:95 android.os.Handler.dispatchMessage	
Looper.java:136 android.os.Looper.loop	
HandlerThread.java:61 android.os.HandlerThread.run

@DonMizzi
Copy link

DonMizzi commented Jan 9, 2022

I confirm this crash on Android 4.4

Amplitude sdk 2.31.1
Okhttp 4.2.2

Has it been fixed with the new versions or is there a workaround?

@justin-fiedler
Copy link
Contributor

Hi @DonMizzi it's possible this is a compatibility issue with OkHttp. OkHttp uses reflection to access some parts of the Android SDK so is strongly coupled with the version of Android. Can you please try another version of OkHttp and see if that fixes the issue?

More information here:
#309 (comment)

@chrisvire
Copy link

okhttp3 4.2.2 requires API Level 21+

https://square.github.io/okhttp/#requirements

OkHttp works on Android 5.0+ (API level 21+) and Java 8+.

To support older devices could be challenging ...

The OkHttp 3.12.x branch supports Android 2.3+ (API level 9+) and Java 7+. These platforms lack support for TLS 1.2 and should not be used. But because upgrading is difficult, we will backport critical fixes to the 3.12.x branch through December 31, 2021.

@chrisvire
Copy link

chrisvire commented Mar 28, 2022

v2.24.0 switch from okhttp3 3.10 (used in v.2.23.2) to okhttp3 4.2.2 which has a requirement on API 21. okhttp3 3.12.2 has an API 9+ requirement. That is quite a change in dependencies without any notice in the release notes!

@haoliu-amp, if a developer want to support API 19, then they should use Amplitude 2.23.2 and okhttp3 3.12.2?

@qingzhuozhen
Copy link
Contributor

We now have a new Android Kotlin SDK now! Feel free to check it out and let us know if any feedback! That library is not using okhttp as part of dependency now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants