Ionic cordova build android error

Ionic cordova build android error

I have installed Ionic and downloaded androis studio ide and installed in my mac. When I try to build my ionic app I have failed with an error like

“Failed to find ‘JAVA_HOME’ environment variable. Try setting it manually andrioid studio”

After a few research I have found the solution for this error :

Open Android Studio Menu > Preferences.
Appearance & Behaviour > System Settings > Android SDK => There you can find your android studio installed location and export it in your bash_profile.

Once this fixed. I have run Ionic cordova build android again, and failed the error below

“Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio “

After few research this I have realised we need to install gradle to build an andriod application. By using below link you can install the gradle manually.

// In my case I have file in dowload folder So my command is unzip -d /opt/gradle downloads/

Once this over run the build command again. I have faced with error like

“You have not accepted the license agreements of the following SDK components”

Again after some search found the solution 

Now I can build and run the andriod application in mac.
Hope it will help someone.