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

simple GET request fails with IllegalAccessError OkHttp3 #871

Open
doums opened this issue Jun 22, 2023 · 10 comments
Open

simple GET request fails with IllegalAccessError OkHttp3 #871

doums opened this issue Jun 22, 2023 · 10 comments

Comments

@doums
Copy link

doums commented Jun 22, 2023

Hi, using 3.0.0-alpha1 on my android project when I make a simple GET request on a healthy URL I get the following exception and the request fails:

java.lang.IllegalAccessError: Field 'okhttp3.OkHttpClient$Builder.eventListenerFactory' is inaccessible to class 'okhttp3.OkHttpClient' (declaration of 'okhttp3.OkHttpClient' appears in ../base.apk!classes4.dex

code

import fuel.Fuel
import fuel.get

val spUrl = "https://google.com"
val res = Fuel.get(spUrl)   // <- throws exception

I'm not sure if it's a bug in the lib or something related to my android project?

@iNoles
Copy link
Collaborator

iNoles commented Jun 23, 2023

Are you override the okhttp versions in your apps? Fuel 3x uses okhttp 5.

@doums
Copy link
Author

doums commented Jun 26, 2023

Nope, you can find the build.gradle here https://github.com/nymtech/nym/blob/bbce67902b1040d9cc5a3b609215a885291e30b6/nym-connect/native/android/app/build.gradle#L126C42-L126C46

Could it be related to proguard? Like a missing rule?

@iNoles
Copy link
Collaborator

iNoles commented Jun 27, 2023

Oh okay, I think I figured out what went wrong.

on alpha1, I had okhttp as implementation instead api. The snapshot already had api. I believe your android apps is looking at the okttp library, but it is not found. Hence errors. As for temporary workaround, you can put okhttp 5 library on your apps.

@doums
Copy link
Author

doums commented Jun 28, 2023

Adding okhttp in build.gradle dependencies does not solve the problem

    implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.11'

I still get the same error

@doums
Copy link
Author

doums commented Jul 12, 2023

@iNoles any news on this?

@iNoles
Copy link
Collaborator

iNoles commented Jul 12, 2023

Sorry, no updates for now.

@doums
Copy link
Author

doums commented Jul 12, 2023

Ok sorry to bother you, but do you have an idea of what could be the issue? I shared my project link, so it might help you to identify the issue.
If not I will drop fuel to use another solution to make HTTP requests. To bad but I don't have really the choice.

@iNoles
Copy link
Collaborator

iNoles commented Jul 24, 2023

I built my own News app that uses Fuel 3.0 alpha 01 and compose multiplatform. https://github.com/iNoles/News

I hope it would help you.

@doums
Copy link
Author

doums commented Jul 25, 2023

Thx, but no it does not help since your android project is almost empty (you forgot to push maybe?).

Anyway, I downgraded to latest stable 2.3.1 and the library works as expected.
But I left the issue open for 3.0.0-alpha1.

@iNoles
Copy link
Collaborator

iNoles commented Jul 25, 2023

That is because shared modules contain the android library.

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

No branches or pull requests

2 participants