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.