Как я могу использовать пакеты JDK в модульных тестах в проекте Android?JAVA

Программисты JAVA общаются здесь
Гость
Как я могу использовать пакеты JDK в модульных тестах в проекте Android?

Сообщение Гость »


Мой проект представляет собой библиотеку Android, поэтому, естественно, у меня есть

Код: Выделить всё

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

Вернуться в «JAVA»