0

I'm using Android Studio Electric Eel | 2022.1.1 for a school project and I need to use an API. In order to use the API I need to send an HTTP request to a certain URL. I read about java 11's HttpClient and HttpRequest from the package java.net.http and tried to use it but the android studio can't seem to find this package and puts the error:

error: package java.net.http does not exist import java.net.http.HttpClient;

I tried checking why it may show this error and I checked the gradle jdk version but it shows that it is version 11.

android studio gradle version

eladGN
  • 13
  • 3
  • Despite sharing a huge chunk of the APIs, Android *is not* Java. So while "the basics" are very similar, newer stuff usually takes a while to arrive at Android and/or won't be supported ever. – Joachim Sauer Apr 11 '23 at 15:53

1 Answers1

1

Android has a long history of not having traditional Java packages outside of the core collections and objects, let alone any Java features beyond Java 7 (java.time as one example).

Android has its own HTTP client library, as documented in the Connectivity guide, or you can opt for other libraries like Retrofit, for example.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245