Could not find tools.jar. Ionic Android

If you are getting the following error while running npx cap run android

 > Could not find tools.jar. Please check that /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
        contains a valid JDK installation.

then you need to follow the following steps to fix that issue:

Install JDK. The steps ccould be different for your machine. You can follow for other versions.

RUn the echo $JAVA_HOME to get the JDK path

echo $JAVA_HOME 

Output will be like this:


Open file present in android folder in your Ionic project.

Add the following line to the last of that file:

The jdk1.8.0_331.jd folder could be different depending upon your JDK location.

Running npx cap run android again will work and will launch your Andoird simulator.