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
1 post - 1 participant