9

I'm editing java files in a package of my flutter project, but it is build with source 1.7, how can I change it?

enter image description here

[√] Flutter (Channel dev, 1.27.0-8.0.pre, on Microsoft Windows [Version 10.0.18363.1440], locale ru-RU)
• Flutter version 1.27.0-8.0.pre at C:\Users\USER\flutter
• Framework revision b7d4806243 (5 weeks ago), 2021-02-19 09:22:45 -0800
• Engine revision 6993cb229b
• Dart version 2.13.0 (build 2.13.0-30.0.dev)

[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\USER\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.

[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
   https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
   https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

enter image description here enter image description here

Dmitry Podbolotov
  • 153
  • 1
  • 2
  • 7
  • make sure your JAVA_HOME point to the target JDK ? – Med Elgarnaoui Mar 29 '21 at 11:55
  • @elgarnaoui yes – Dmitry Podbolotov Mar 29 '21 at 13:10
  • Go to File > Project Structure. Select the SDK Location section in the list of the left. Deselect the Use embedded JDK (recommended) option. Enter the absolute path of your installed JDK in the text box. – Med Elgarnaoui Mar 29 '21 at 13:14
  • Finally, Verify your Flutter points to JDK, here it is pointing to JRE not JDK, once you make changes as suggested by elgarnoui –  Mar 29 '21 at 13:20
  • @elgarnaoui, you can see my Project Structure window on the second image from the bottom. Looks like 'Use embedded JDK' has been removed in 4.x, so correct path to jdk is set in '15', which is also selected in all 'Android API Platform'. – Dmitry Podbolotov Mar 29 '21 at 14:24
  • take a look at https://stackoverflow.com/questions/19608742/how-to-set-java-sdk-path-in-androidstudio – Med Elgarnaoui Mar 29 '21 at 17:35
  • I'm having the same issue, how did you solve it? – Sakorni Jul 13 '21 at 16:59
  • Same here, tried all of the above but it will always stay on the Android Studio embedded JDK. – Sebastian Sep 21 '21 at 07:06
  • An complete image about how can be changed Java version in Windows is provided in https://www.happycoders.eu/java/how-to-switch-multiple-java-versions-windows/ – Mihai8 Dec 31 '21 at 19:56

1 Answers1

1

Make the switch to JDK 11 by following the steps in this post. Once done, restart Android Studio and try clearing its cache.

Omatt
  • 8,564
  • 2
  • 42
  • 144