JAVA_HOME is not set and no 'java' command could be found in your PATH

I tried to run my flutter android project from github repo with emulator, but this error comes up

I had same problem.
to solve the issue, I created a flutter project using idx itself.
there in directory idx gave a folder “.idx” and a file “dev.nix” inside it.
you just also need to create “.idx” folder in your project imported from github and “dev.nix” file inside this folder and copy paste the code of “dev.nix” file.

then run your app, it might crash for the first time, but run it again and it’ll work.

Can you explain in detail ?

JAVA HOME error is coming because IDX uses its own environment to set all variables like JAVA HOME.
When you import github repo as a IDX project, IDX actually does not know about its configuration.

So just to fix the configuration I followed following steps:

  1. create a new flutter project in idx.
  2. open your flutter project in idx as well in new tab.
  3. create .idx folder in root directory of your flutter project (github one)
  4. copy and paste the dev.nix file from newly created .idx folder into your recently created .idx folder in your flutter project.
  5. run your flutter code, it might crash for first time, But it will run with all configuration including JAVA HOME.