When running ./gradlew clean build
I get following message:
> Task :compileKotlin FAILED
FAILURE: Build failed with an exception.
* What we
I solved a similar problem in MacOS (Big Sur). In my case I was running a React Native project and got the following error when trying to build to Android:
* What went wrong:
Execution failed for task ':bugsnag_react-native:compileDebugKotlin'.
> Kotlin could not find the required JDK tools in the Java installation '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home' used by G
radle. Make sure Gradle is running on a JDK, not JRE.
I followed this article for uninstalling the JRE on MacOS. Slightly modified to make the process reversible, here are the steps:
cd /Library/Internet\ Plug-Ins/
mv JavaAppletPlugin.plugin DELETED-JavaAppletPlugin.plugin
cd /Library/PreferencePanes/
mv JavaControlPanel.prefPane DELETED-JavaControlPanel.prefPane
When you receive Permission denied
use sudo
before commands.
I then cleared my Gradle folder. I don't know if this is necessary, but it worked for me:
rm -rf ~/.gradle
Finally, I rebuilt my project (react-native run-android
) and everything worked.
I'm not sure removing the JRE is the best solution since you may need the JRE for other things, but I have not noticed any ill effects. Also, it appears I already had a JDK installed which may not be true for all Mac users.
Since there are not any good answers on Stack Overflow that address this problem on MacOS, I figured I'd post my solution here.