Hitting a bit of a wall here when trying to build a brand new flutter sandbox application within IntelliJ for Android.
The error that I get is the following:
java: Cannot run program "/Users/vintrin/Library/AndroidStudio/sdk/bin/java" (in directory "/Users/vintrin/Library/Caches/JetBrains/IntelliJIdea2022.3/compile-server"): error=2, No such file or directory
This file /Users/vintrin/Library/AndroidStudio/sdk/bin/java in fact does NOT exist.
I am starting the IntelliJ from my terminal to get all the environment variables to be recognized by IntelliJ using
open -na "IntelliJ IDEA.app"
Below you can see the print out of the values from within the IntelliJ terminal:
Viktors-MacBook-Pro:flutter_sandbox vintrino$ echo $JAVA_HOME
/usr/local/Cellar/openjdk#11/11.0.17
Viktors-MacBook-Pro:flutter_sandbox vintrino$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/findutils/libexec/gnubin:/Users/vintrin/.nvm/versions/node/v15.14.0/bin:/Users/vintrin/Library/AndroidStudio/sdk/emulator:/Users/vintrin/Library/AndroidStudio/sdk/tools:/Users/vintrin/Library/AndroidStudio/sdk/tools/bin:/Users/vintrin/Library/AndroidStudio/sdk/platform-tools:/Users/vintrin/Library/AndroidStudio/sdk/cmdline-tools/latest/bin:/Users/vintrin/.toolbox/bin:/apollo/env/envImprovement/bin:/Users/vintrin/bin:/Users/nkondrat/vintrin-env/home_dir/python:/apollo/env/SDETools/bin:/apollo/env/GordianKnot/bin:/apollo/env/OctaneBrazilTools/bin:/apollo/env/envImprovement/jdk1.8/bin:/Users/nkondrat/apps/phantomjs-2.1.1-macosx/bin:/apollo/env/AmazonAwsCli/bin/:~/.rodar/bin:/Users/nkondrat/vintrin-env/home_dir/js/cli:/Users/vintrin/software/flutter/bin
Viktors-MacBook-Pro:flutter_sandbox vintrino$
The Intellij project is set to use Android33 API
The SDK is set here in Intellij
And the SDK is said to be installed by Android Studio
Running the following from intellij terminal to check java installation
Viktors-MacBook-Pro:flutter_sandbox vintrino$ $JAVA_HOME/bin/java --version
openjdk 11.0.17 2022-10-18
OpenJDK Runtime Environment Homebrew (build 11.0.17+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.17+0, mixed mode)
However for whatever reason when IntelliJ builds it tries to use java that doesn't exist at path:
/Users/vintrin/Library/AndroidStudio/sdk/bin/java
The flutter doctor command is happy for android
mac> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.3.10, on macOS 11.4 20F71 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
How do I resolve java not being found?
I installed Android Studio 4.1 and tried to run the existing project. But it gives an error like this:
ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
You have to set the JAVA_HOME Environment Variable.
On Windows, I solved the issue as follows:
Download the Java JDK from here and install it. (This links to version 15, which requires you to create an account in order to download. Version 16 is available to download without creating an account, but it has caused me an error that required me to downgrade.)
Set the "JAVA_HOME" Environment Variable:
Open Windows Search, type in “env”, and choose “Edit the system environment variables”.
Click on "Environment Variables...".
Click on "New".
Fill in the "variable name" field with "JAVA_HOME".
Fill in the "variable value" with the path to where Java is installed on your computer. (for me it was under "C:\Program Files\Java\<jdkversion>".)
Click "OK" and close all dialogs.
Restart your IDE / Terminal. (do not skip this step)
On Ubuntu 20.04 with Android 4.1, this error can be solved using the Snap version with:
flutter config --android-studio-dir=/snap/android-studio/current/android-studio
For Windows :
flutter config --android-studio-dir="C:\Program Files\Android\Android Studio"
This command works fine if you have Android Studio installed. Flutter can understand the configurations of the Android Studio and you don't have to provide JAVA_HOME anymore.
Edit (Bonus) :
Also, download "Android SDK Command-line Tools" in android studio for android-licenses. Steps are shown in the image below.
You need to install Java JDK software which is required for the android studio.
sudo apt install openjdk-11-jdk
UPDATE: run flutter upgrade to upgrade to Flutter 1.22.2, which fixes compatibility issues with Android Studio 4.1. See related Flutter release.
This issue has been resolved v
See this issue regarding Android Studio 4.1 and Flutter
You can either downgrade back to Android Studio 4.0.2 or you can
install the latest JDK and update your JAVA_HOME variable and
PATH (OS dependent).
Note that if you choose to continue using 4.1 instead of downgrading,
flutter doctor will tell you Android Studio is not installed.
You need to run flutter config --android-studio-dir='<path to android studio>' in order to fix this issue. flutter doctor will now also
incorrectly report that the Flutter and Dart plugins are not
installed even if they are - you can ignore this.
Install Android Studio (skip this step if you already installed)
Goto
C:\Program Files\Android\Android Studio\jre and copy the path.
Make New variable called "JAVA_HOME". And paste above path as the variable value.
I set my JAVA HOME to the path,
/snap/android-studio/97/android-studio/jre/
Then I set my android studio config in flutter by using this command:
flutter config --android-studio-dir=/snap/android-studio/current/android-studio
My system is :
Ubuntu 20.04 with Flutter plugin version as 4.1,
In Mac:
In your terminal run
ECHO $JAVA_HOME
This will bring up the current path of java home.Pay close attention to the path that the terminal outputs.In my case i had System/Library instead of /Library/.../... typo as my path.So i simply corrected this in bash_profile.
If your path is correct but the error persists,
Right Click On Finder
Go To Folder
Bash_Profile
Add or Edit the Java Home Path
The path you add here should be the one your terminal output when you ran Echo $Java_Home..As long as this path that was echoed was/is correct..the below steps should fix the issue.
Then open your zshrc in a similar manner as you did with bash_profile and add the home path to the file.
You can also edit the bash_profile and zshrc files in your text editor.These files can be displayed using cmd + shift + . in your home folder.
After that,save,exit the terminal, close android studio and restart your machine.
Read this Article to learn more.
Locate where your Android Studio is installed.
For me C:\Program Files\Android\Android Studio
Check if the jre folder exists, Create a new folder called jre
Copy the contents of the jbr folder and paste them into the jre folder.
Check by running flutter doctor, and Restart IDE.
Thanks: roufy235 {cause}
For ubuntu 20.04 this solution will be appropriate: -
This link solved my problem. In short I would recommend to follow the simple steps, i.e.
Upgrade the flutter using flutter upgrade
Set the path of the flutter flutter config --android-studio-dir="/path/to/android/studio/"
Set the path in bashrc file by opening bashrc file(it is a hidden file)
export JAVA_HOME="/path/to/android/studio/jre/"
choco install javaruntime
If you use choco package manager. It will set the vars automatically.
This issue can also be caused if you have updated your Android Studio.
In that case.
For Windows
First Open the Users\username\AppData\Local\Google directory on your PC/Laptop and make sure to Delete the older version of your Android Studio.
e.g, Current version of Android studio is Electric Eel (2022.1).
Delete any other older version from that directory accordingly and restart your PC or Laptop.
Then try running your project.
Install openjdk-8 ....
You have to restart your terminal, the issue will persist even after download if you don't restart the terminal.
Follow react native guide to download openjdk for your environment. ...
https://reactnative.dev/docs/environment-setup
For Windows this worked
Go to C:\Program Files\Android\Android Studio.
Copy all the files inside of jbr directory.
Paste all the files into jre directory.
Then run flutter doctor. The issue will go away.
D:\Flutterproject\rechyriedapp>flutter doctor -v
[√] Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.22621.1105], locale en-IN)
• Flutter version 3.3.8 on channel stable at C:\flutter_windows_3.3.8\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52b3dc25f6 (3 months ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\USER\AppData\Local\Android\Sdk
• Platform android-TiramisuPrivacySandbox, build-tools 33.0.0
X No Java Development Kit (JDK) found; You must have the environment variable JAVA_HOME set and the java binary in your PATH. You can download the JDK from https://www.oracle.com/technetwork/java/javase/downloads/.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33213.308
• Windows 10 SDK version 10.0.22000.0
[!] Android Studio (version 2022.1)
• 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
X Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[√] Connected device (4 available)
• CPH2095 (mobile) • 86db9605 • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1105]
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.120
• Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.55
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 2 categories.
After that copy all file from jbr to jre
D:\Flutterproject\rechyriedapp>flutter doctor -v
[√] Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.22621.1105], locale en-IN)
• Flutter version 3.3.8 on channel stable at C:\flutter_windows_3.3.8\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52b3dc25f6 (3 months ago), 2022-11-09 12:09:26 +0800
• Engine revision 857bd6b74c
• Dart version 2.18.4
• DevTools version 2.15.0
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\USER\AppData\Local\Android\Sdk
• Platform android-TiramisuPrivacySandbox, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.4.4)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.4.33213.308
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2022.1)
• 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 11.0.15+0-b2043.56-8887301)
[√] Connected device (4 available)
• CPH2095 (mobile) • 86db9605 • android-arm64 • Android 12 (API 31)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22621.1105]
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.120
• Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.55
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Download Liberica JDK and on installation it will automatically set JAVA_HOME environment variable.
Now you just go to Android Studio -> Project Structure -> SDK -> Point all jdk path to liberica jdk installation directory and apply.
You are done. Just restart android studio and gradle command will work.
How do i solve this ? I've downloaded Android Studio Preview on my M1 Mac as suggested
error after running flutter doctor
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[✓] Flutter (Channel beta, 2.3.0-24.1.pre, on macOS 11.4 20F71 darwin-arm,
locale fr-FR)
[✗] Android toolchain - develop for Android devices
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[!] Android Studio
✗ Unable to find bundled Java version.
[✓] VS Code (version 1.58.2)
[✓] Connected device (2 available)
why is it still not working ?
I've been using SDK Man for years to install, update and change java versions with simple commands. It will take care of the installation and environment variable setup as well.
Here is a simple guide for mac users
Once the sdkman is installed, you can use it from the commandline:
sdk ls java
It will return a table with all the available versions.
The cleanest choice is the lastest 'official' LTS version, where the vendor is Java.net and the current latest version is 11.0.11-open
Sdkman also helps you with a command sample at the bottom of the table, so for the current latest LTS openJDK, I would go with:
sdk install java 11.0.11-open
And that's all. Or if you have previously installed java versions (installed through other means) it is best to remove them.
Make sure you have a JDK installed (you can get it here) and your $PATH and $JAVA_HOME are set up correctly. These sources can really help:
https://mkyong.com/java/how-to-set-java_home-environment-variable-on-mac-os-x/#what-is-usrlibexecjava-home
http://www.sajeconsultants.com/how-to-set-java_home-on-mac-os-x/
https://docs.oracle.com/javase/9/install/installation-jdk-and-jre-macos.htm#JSJIG-GUID-5F4A0659-BFC5-4CB9-9920-D2DEABF29894
https://medium.com/notes-for-geeks/java-home-and-java-home-on-macos-f246cab643bd
In case you've already set them up, double check what's going on with your JAVA_HOME by pasting this in terminal:
echo $JAVA_HOME
It should output a path like this (the jdk version may vary):
/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
If it the path looks the same (or same with different java version), and you have also checked "where java", "java -version" etc, to make sure that the terminal recognises your java well and there is no other obvious java issue, that means that the only thing left is to run these commands one by one:
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
Now if you run "flutter doctor -v", you should see no java errors and something like this instead of the previous error:
• Java binary at: /Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
Hope this helps! It solved the issue for me :)
These answers might help too:
Unable to find bundled Java version. MacBook Air M1
Unable to find bundled Java version on Flutter
Flutter-Unable to find bundled Java version(flutter doctor), after updated android studio Arctic Fox(2020.3.1) on M1 Apple Silicon
Everything was working fine 4 days ago - I did an update and the licenses stopped going through... what I did so far.
the tools obsolete thing is checked -> does not work
flutter doctor --android-licenses -> does not work
sdkmanager --licenses -> did not work
uninstall and reinstall android at least 3 times -> did not work
downloaded manually cmdline-tools folder and put in the Sdk folder -> did not work
delete folder tools and replaced with new one -> did not work
flutter doctor
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
X Android license status unknown.
flutter doctor --android-licenses
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
Flutter 1.17.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision e6b34c2b5c (7 days ago) • 2020-05-02 11:39:18 -0700
Engine • revision 540786dd51
Tools • Dart 2.8.1
$ java --version
openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
Android Studio 3.6.3
I encountered the same problem just recently. I solved mine with the ANDROID_HOME path in the Environment Variables.
my solution for the licenses - after 6 days...
uninstall everything JAVA AS WELL.
then reinstall javaSE (jdk8) and reinstall everything openJDK11 as JAVA_home path.
flutter doctor will ask you to do --android-license .
Steps to Reproduce
I am running flutter in windows 10. I previously had a running android setup. After cloning the flutter repo and updating path, I ran flutter doctor -v. The logs are below. Now after searching a bit for solving the problem, I came across to this solution from various stackoverflow answers: Flutter.io Android License Status Unknown
I at first executed this:
set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
Though I don't know how to make it permanent. Then after running flutter doctor again, I came with another message, see log ###2
So it says Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4). So I ran flutter doctor --android-licenses accordingly. And it gives another error, that is:
A newer version of the Android SDK is required. To update, run:
C:\Users\imazi\AppData\Local\Android\sdk\tools\bin\sdkmanager --update
Well, so I ran C:\Users\imazi\AppData\Local\Android\sdk\tools\bin\sdkmanager --update to update it. And it kinda updated successfully outputting [=======================================] 100% Computing updates...
So I thought the issue is solved and ran flutter doctor again but it seems that nothing has been changed the problem still remains. It is like a loop. I do everything and the problem remains as it is. The output of the last flutter doctor is in log ### 3
My java version is:
10.0.2 2018-07-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.2+13)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.2+13, mixed mode)
Please help.
!! also opened a github issue here: https://github.com/flutter/flutter/issues/39637
Logs
1 flutter doctor -v
O:\Flutter installation>flutter doctor -v
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Active code page: 1252
Microsoft Windows [Version 10.0.18362.295], locale en-US)
• Flutter version 1.7.8+hotfix.4 at O:\Work_Anon\Flutter installation\flutter
• Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
**• Android SDK at C:\Users\imazi\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• Java binary at: O:\Work_Anon\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
**X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit
https://flutter.dev/setup/#android-setup for detailed instructions.****
[!] Android Studio (version 3.4)
• Android Studio at O:\Work_Anon\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[!] Connected device
! No devices available
2 flutter doctor after set JAVA_OPTS=-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Active code page: 1252
Microsoft Windows [Version 10.0.18362.295], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
3 last flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Active code page: 1252
Microsoft Windows [Version 10.0.18362.295], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1))
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[!] Android Studio (version 3.4)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
Actually, the problem got solved after installing jdk 8 and setting JAVA_HOME accordingly this new jdk. Also in the sdkmanager.bat file, located in C:\Users\username\AppData\Local\Android\Sdk\tools\bin
I added the line set JAVA_HOME="C:\Program Files\Java\jdk1.8.0_221"
No need to uninstall java 10. That solved the whole problem!
Check if the flutter path is added.
Restart your system
Then run flutter doctor --android-licenses
accept all the licenses that appear
again run flutter doctor
and check if the issue persists
I uninstall the java jdk from my system and then let my flutter doctor arise that error of " [!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)"
and then followed the solution that flutter doctor was giving as it says to run the command " flutter doctor --android-licenses " and then type " y " as it says you to accept the licenses provided to solve this problem of "[!] Android toolchain - develop for Android devices (Android SDK version 29.0.1)" and then I again ran flutter doctor and the problem was resolved.