1

I need to change targetSdkVersion in my project from 29 to 30 so I have to use Java 11 in my project. In build.gradle(:app) I' ve changed

sourceCompatibility JavaVersion.VERSION_1.8
targetCompatibility JavaVersion.VERSION_1.8

to

sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11

After this I got this error:

Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'.

I have both JDK 1.8 and 1.11, but when I type 'java --version' in command line I got:

java 11.0.9 2020-10-20 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.9+7-LTS) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.9+7-LTS, mixed mode)

I found some solutions for this kind of problem for IntelliJ (changing sdk version in gradle settings), but not for Android Studio.

AndroideuszPL
  • 385
  • 1
  • 2
  • 13

1 Answers1

-1

I have the same issue. My android studio version is 3.5.2, and i think it doesn't support JAVA 11. Don't know other better way, here's my solution: Uninstall present version and reinstall android studio 4.2. Note:if the warning ""Installed Build Tools revision 31.0.0 is corrupted" happened, you may see this Android Studio error "Installed Build Tools revision 31.0.0 is corrupted"