Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70817

"Unable to locate a Java Runtime" when building for Android on Mac

$
0
0

The ‘run android’ command kept failing on my Mac (running Big Sur) with the following error:

Running Gradle build - failed!
[capacitor] [error] The operation couldn’t be completed. Unable to locate a Java Runtime.

I struggled for a while with it so just wanted to share what fixed it for me:

  • Check the SDK path in Android Studio (Android Studio > Preferences… > Build, Execution, Deployment > Build Tools > Gradle > Gradle JDK)
  • Set JAVA_HOME to that path in your .zshrc or .bashrc file. For example:
    export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
  • Quit terminal, reopen and try running again

Hope this helps someone :slight_smile:

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 70817

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>