Home > Software design >  Running Gradle build - failed! JAVA_HOME is not set and no 'java' command could be found i
Running Gradle build - failed! JAVA_HOME is not set and no 'java' command could be found i

Time:01-23

I'm attempting to run my Ionic application in an Android emulator in Android Studio using the ionic command in terminal in VSCode:

ionic capacitor run android

But I get the following error when running:

[capacitor] × Running Gradle build - failed!
[capacitor] [error] 
[capacitor]         ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
[capacitor]
[capacitor]         Please set the JAVA_HOME variable in your environment to match the
[capacitor]         location of your Java installation.
[capacitor]

So I set the environment variables as seen here: JAVA_HOME

PATH

But I still get the same error?

When I run the java command in the command line that all runs fine: JavaCMD

CodePudding user response:

Java JDK-11 is mostly compatible with android.

  1. Add correct java path (mostly jre path).
  2. Run the same command and check again.

CodePudding user response:

maybe you can try to running with Android Studio

ionic cap open android

also you can check the doc https://capacitorjs.com/docs/android/troubleshooting

  •  Tags:  
  • Related