amplitude / unity-plugin

Official Amplitude Unity Plugin
https://developers.amplitude.com/docs/unity
MIT License
44 stars 34 forks source link

Amplitude SDK 1.1.0. Crush on Android 4.4.4 #35

Closed N0lex closed 4 years ago

N0lex commented 4 years ago

The latest version of Amplitude SDK 1.1.0 (April 5, 2020) does not work on Android 4.4.4.

Crash Log:

E/AndroidRuntime(22109): FATAL EXCEPTION: logThread E/AndroidRuntime(22109): Process: com.game, PID: 22109 E/AndroidRuntime(22109): java.lang.Error: FATAL EXCEPTION [logThread] E/AndroidRuntime(22109): Unity version : 2019.2.12f1 E/AndroidRuntime(22109): Device model : asus Nexus 7 E/AndroidRuntime(22109): Device fingerprint: google/nakasi/grouper:4.4.4/KTU84P/1227136:user/release-keys E/AndroidRuntime(22109): Caused by: java.lang.ExceptionInInitializerError E/AndroidRuntime(22109): at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:211) E/AndroidRuntime(22109): at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:179) E/AndroidRuntime(22109): at okhttp3.internal.platform.Platform.(Platform.kt:180) E/AndroidRuntime(22109): at okhttp3.OkHttpClient.(OkHttpClient.kt:219) E/AndroidRuntime(22109): at okhttp3.OkHttpClient.(OkHttpClient.kt:211) E/AndroidRuntime(22109): at com.amplitude.api.AmplitudeClient.lambda$initialize$0$AmplitudeClient(AmplitudeClient.java:271) E/AndroidRuntime(22109): at com.amplitude.api.-$$Lambda$AmplitudeClient$9hxT9i3yp7eOymOvTMj42XcPKBs.run(lambda) E/AndroidRuntime(22109): at android.os.Handler.handleCallback(Handler.java:733) E/AndroidRuntime(22109): at android.os.Handler.dispatchMessage(Handler.java:95) E/AndroidRuntime(22109): at android.os.Looper.loop(Looper.java:136) E/AndroidRuntime(22109): at android.os.HandlerThread.run(HandlerThread.java:61) E/AndroidRuntime(22109): Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 19 E/AndroidRuntime(22109): at okhttp3.internal.platform.AndroidPlatform.(AndroidPlatform.kt:232) E/AndroidRuntime(22109): ... 11 more

Please fix!!!

2019.2.12f1 Nexus 7 2012 Windows 10.

haoliu-amp commented 4 years ago

Look like an error from okhttp. May I know which okhttp version are you using?

N0lex commented 4 years ago

@haoliu-amp Please download Amplitude SDK 1.1.0 and you can see the okhttp version. Link: https://github.com/amplitude/unity-plugin/commit/0881abc9883edf5a1f385ef3b4ca92b914594aa9

amplitude_import_sdk

haoliu-amp commented 4 years ago

Amplitude SDK depends on okhttp library. The old SDK is the one using a very old version of okhttp 3.10.0.

Since Amplitude Unity SDK 1.0.0, we updated the okhttp to be 4.2.2, since it fixed a lot vulnerabilities.

However, okhttp dropped the support for < 5.0 since 3.13. Please read this. https://developer.squareup.com/blog/okhttp-3-13-requires-android-5/

But you can still use the new SDK with older version okhttp if you wanna get KitKat supported.

How to do it -

If you import library by copying the jar file, you can downgrade okhttp library by replacing it with a version < 3.13. If you use google dependency resolver, update the dependency version for okhttp in *Dependency.xml file.

N0lex commented 4 years ago

Why is this information missing from the documentation?

Please update your guide: https://help.amplitude.com/hc/en-us/articles/115002991968-Unity-Plugin-Installation

haoliu-amp commented 4 years ago

We will do it. Thanks for your feedback!

haoliu-amp commented 4 years ago

@N0lex We've updated it. https://help.amplitude.com/hc/en-us/articles/115002991968-Unity-Plugin-Installation#running-on-api-19-20-kitkat

Let me know if the issue is solved! Thanks