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

0.36.0 Crash on Android <=9 -> okhttp3 ExceptionInInitializerError #450

Closed
let-it-snow opened this issue Aug 3, 2022 · 6 comments · Fixed by #457
Closed

0.36.0 Crash on Android <=9 -> okhttp3 ExceptionInInitializerError #450

let-it-snow opened this issue Aug 3, 2022 · 6 comments · Fixed by #457

Comments

@let-it-snow
Copy link

let-it-snow commented Aug 3, 2022

What version are you using?

Newest version 0.36.0

What did you do?

Create the org.stellar.sdk.Server("https://horizon.stellar.co/") object in any place of the project -> You will receive the crash: java.lang.ExceptionInInitializerError on the Android version <=9

StandardAndroidSocketAdapter.kt line 61
....
java.lang.ExceptionInInitializerError
        at shadow.okhttp3.OkHttpClient.<init>(OkHttpClient.kt:237)
        at shadow.okhttp3.OkHttpClient$Builder.build(OkHttpClient.kt:1069)
        at org.stellar.sdk.Server.<init>(Server.java:58)

Steps to reproduce:

  • Create a new Kotlin project in the Android Studio.
  • Apply Java Stellar SDK 0.36.0.
  • Create org.stellar.sdk.Server("https://horizon.stellar.co/") object in any place.
  • Run the project on the Android <= 9 and immediately receive the ExceptionInInitializerError.

What did you expect to see?

No any crashes.

What did you see instead?

Crash on the Android <=9.

Thanks.

@let-it-snow let-it-snow added the bug label Aug 3, 2022
@let-it-snow let-it-snow changed the title 0.36.0 Crash -> okhttp3 ExceptionInInitializerError 0.36.0 Crash Android <=9 -> okhttp3 ExceptionInInitializerError Aug 3, 2022
@let-it-snow let-it-snow changed the title 0.36.0 Crash Android <=9 -> okhttp3 ExceptionInInitializerError 0.36.0 Crash on Android <=9 -> okhttp3 ExceptionInInitializerError Aug 3, 2022
@sreuland sreuland moved this to Backlog in Platform Scrum Sep 13, 2022
@sreuland sreuland moved this from Backlog to Next Sprint Proposal in Platform Scrum Sep 13, 2022
@sreuland
Copy link
Contributor

@let-it-snow , can you provide which version of Android Studio, I'm trying 2021.2.1, and how do you enact Run the project on Android <= 9? What version is the 9 referring in Android Studio settings? thanks! I was starting with a new Basic Activity project to replicate.

@let-it-snow
Copy link
Author

@sreuland Hi,

  • Android Studio Chipmunk | 2021.2.1
  • Set the Minimum SDK e.g. API 22.
  • Create Basic Activity.
  • Apply latest Stellar SDK to depedencies.
  • Into Basic Activity apply the code like: org.stellar.sdk.Server("https://horizon.stellar.co/").
  • Run the project on the Android 9 (Api Level 28) emulator.

@quietbits
Copy link

@sreuland you can try this demo project that demonstrates this issue with the latest Java Stellar SDK.

Attached is a screen recording of what happened. The crash doesn't happen when using an emulator with API 30, but it crashes with API 21 (not sure what is the latest API version that works).

java-stellar-sdk-android-api21-error.mp4

@sreuland
Copy link
Contributor

@lijamie98 @marcelosalloum , any thoughts on this android runtime conflict as well, wondering if maybe it's time to just replace okhttp with a different lib like apache httpclient to avoid it

@lijamie98
Copy link
Contributor

I remember seeing this. If I remember it correctly, it has some conflict with the library shipped with Kotlin.

I am not sure if replacing okhttp would avoid the problem though.

@jcx120
Copy link

jcx120 commented Nov 21, 2022

@lijamie98 is this still an issue or have you been able to resolve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants