kittinunf / fuel

The easiest HTTP networking library for Kotlin/Android

Home Page:https://fuel.gitbook.io/documentation/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

simple GET request fails with IllegalAccessError OkHttp3

doums opened this issue · comments

commented

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?

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

commented

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?

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.

commented

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

commented

@iNoles any news on this?

Sorry, no updates for now.

commented

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.

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.

commented

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.

That is because shared modules contain the android library.