React Native Android : FAILURE: Build failed with an exception. MAC OS
Tags: adoptopenjdk8
Published: 2021-04-19 16:29:01

---
title: React Native Android : FAILURE: Build failed with an exception. MAC OS
published: true
description: Task :app:compileDebugJavaWithJavac FAILED 
tags: adoptopenjdk8
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mm7z9l0q5lcpsoneys0u.png
---

This is an issue with how Gradle is automating the build and the current version of the JDK installed on your machine, follow these steps to fix it, the react native documentation states you need adoptopenjdk8, however you may have other conflicting JDK versions in the same directory.

Firstly: Recreate this error

In order to recreate this Error install a newer version of JAVA Development Kit for example JDK 16, or more than one JDK's on your mac.

https://www.oracle.com/java/technologies/javase-jdk16-downloads.html

If you run npx react-native run-android, You'll get the following build fail:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2r6ejyi8jmq9qi0oe3e.png)


Your build may be failing because :

• More than one JDK's are installed.

• Incompatible JDK is installed.

• Or no JDK is installed.

This is an issue with how Gradle is automating the build and the current version of the JDK installed on your machine, the react native documentation states we need adoptopenjdk8, however you may have other conflicting JDK versions in the same directory.

So to fix this issue follow these steps:

***Step One:***

Open up your terminal and navigate to /Library/Java/JavaVirtualMachines by typing the following command:

```cd /Library/Java/JavaVirtualMachines```


after you have done that type "ls" to see what files are included and take note of the versions, incase you have one or multiple JDK files present like such:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sj37pahlktcupytqpdrg.png)


delete them with the following command line :

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qgslu4lhnsdqvn3vhvs2.png)

the only dependency you need is adoptopenjdk-8.jdk as mentioned in the react native docs.

however delete that as-well and reinstall it after you have completed these steps.

After you have done so you can check if the files still exist by typing "ls" if the files are deleted.

Then run the following commands to insure all other links, plugins and files are deleted as-well from your Library:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iwe09yyk9sg9dic7pgl3.png)


**Step Two:**

Once all JDK's have been removed reinstall the correct JDK as mention in the react-native documentations.

Open up a new terminal

https://reactnative.dev/docs/_getting-started-macos-android

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0fsdb9gnbz5oc3bnc54u.png)

This may say adoptopenjdk-8.jdk is already installed:


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j7ak5ak98d72l5uiwt11.png)


regardless, go ahead and reinstall it with:


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ut753wc8dn7xll5r7bao.png)

Once installation is complete, you should see the following:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/baolloni0zi7cjbxq8ds.png)

At this point the error should be resolved and your build should work.

***To Conclude***

It is important to note that this is a build error, since react native uses Gradle to build automations, the conflicting of multiple jdk versions can cause your build to fail.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gfavp48cxgqg7dkw0dvi.png)

please refer to the following documentation to get a better understanding on Gradle compilation.

*https://docs.gradle.org/current/userguide/userguide.html*