https://kotlinlang.org logo
#ktor
Title
# ktor
e

Emirhan Emmez

03/05/2023, 1:04 PM
Hi, I'm getting this error when I create a client with Hilt:
java.lang.NoSuchMethodError: No virtual method getModule()Ljava/lang/Module; in class Ljava/lang/Class; or its super classes (declaration of 'java.lang.Class' appears in /apex/com.android.art/javalib/core-oj.jar)
Here is my code:
Copy code
@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {
    @Provides
    @Singleton
    fun createKtorClient(): HttpClient =
        HttpClient(CIO).config {
            defaultRequest {
                url("<http://localhost:8080/>")
                contentType(ContentType.Application.Json)
                accept(ContentType.Application.Json)
            }
            install(Logging) {
                level = LogLevel.ALL
            }
            install(ContentNegotiation) {
                json()
            }
        }
}
152 Views