Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Android studio 4.2 Preview having this error when creating buildSrc and build.gradle.kts

I am trying to use buildSrc for dependency management in the new Android 4.2 Preview version and getting this error.

Cannot access 'java.lang.Object' which is a supertype of 'org.gradle.api.artifacts.repositories.MavenArtifactRepository'. Check your module classpath for missing or conflicting dependencies
Cannot access class 'java.net.URI'. Check your module classpath for missing or conflicting dependencies
like image 710
Mohammad Elsayed Avatar asked Jan 12 '21 12:01

Mohammad Elsayed


1 Answers

I figured it out, it's due to the Java default JDK coming with the new Android Studio, I believe this will be fixed in the release version.

To quickly fix this there are two options:

  1. Use the JDK of the previous release Android Studio if you have not deleted it (recommended because I tested that).
  2. Download Java JDK and install it and get it's directory and attach it to JDK directory in the new Android studio.

How to change the JDK in Android studio.

  1. File ->
  2. Project Structure ->
  3. On the left find "SDK Location" ->
  4. at the bottom you will find "JDK Location" change this to the same directory either of the old Android studio or the location of Java JDK that you installed manually from Oracle official website.
like image 127
Mohammad Elsayed Avatar answered Oct 11 '22 03:10

Mohammad Elsayed