My project is an Android library, so naturally I have plugins { id 'com.android.library' } in my build.gradle. This has unexpected effect that in unit tests imports like import java.net.http.HttpClient; cannot be resolved...

Indeed, I am aware that Android platform includes not even nearly all JDK classes, especially those found in newer JDKs.
But that applies only to the code which runs in Android, doesn't it? A unit test which runs on my host machine (i.e. not in Android but in the JDK) - why would it not see java.net.http.HttpClient of my host JDK? I assume that the compiler error I'm getting is result of a misconfiguration in Gradle.
I want to use such JDK classes in my unit tests. Is there a magic line in Gradle that I miss?
Источник: https://stackoverflow.com/questions/781 ... id-project