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

fix okhttp3 class loader issue on android platform #457

Merged
merged 1 commit into from
Dec 2, 2022

Conversation

sreuland
Copy link
Contributor

@sreuland sreuland commented Dec 2, 2022

I was able to replicate this problem in Android studio using emulator set at SDK version 28( android 'pie'):

The underlying issue was due to the shadowed jar, which rewrote an unintended 'com.android.org.conscrypt' hardcoded reference in the okhttp3 platform initialization which uses that as default to initialize networking from android:

https://github.com/square/okhttp/blob/parent-4.10.0/okhttp/src/main/kotlin/okhttp3/internal/platform/android/StandardAndroidSocketAdapter.kt#L61

it had a cycle when in error, trying to reference the platform instance while it was inside the platform init routine.

to avoid the problem, I tweaked the shadow config to ignore com.android.org.conscrypt ,which stops it from trying to rewrite any refs to that in the .class files in the shadowed jar.

after this change, I was able to verify the fix by running the same prior failing example with org.stellar.sdk.Server("https://horizon.stellar.com/") and OkHttpClient() which now worked.

Closes #450

@sreuland sreuland requested review from a team and lijamie98 December 2, 2022 05:32
Copy link
Contributor

@marcelosalloum marcelosalloum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tsachiherman
Copy link

It would be great if we had a unit test that reproduces this issue - but I don't know how feasible it would be to implement such a test.

@sreuland
Copy link
Contributor Author

sreuland commented Dec 2, 2022

It would be great if we had a unit test that reproduces this issue - but I don't know how feasible it would be to implement such a test.

yes, created ticket to track - #458

@sreuland sreuland merged commit 35fdf01 into lightsail-network:master Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.36.0 Crash on Android <=9 -> okhttp3 ExceptionInInitializerError
3 participants