I'm working on an simple android kotlin project which use the build-in java.net.http.HttpClient to make http post request, but it always failed to build, the error is:
Unresolved reference: http
Unresolved reference: HttpClient
Unresolved reference: HttpRequest
Unresolved reference: HttpResponse
settings in build.gradle
:
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
The gradle JDK location and my JAVA_HOME
variable point to the same environment which is the build-in version 11.0.3 under my-android-studio-path/jre
PS: I've read this answer before I post but unfortuntely it did not help, I don't know if there's something I missed.