3

ionic capacitor run android failed when running build gradle. gradle failed

'* What went wrong: Supplied javaHome must be a valid directory. You supplied: C:\Program Files\Java\jre1.8.0_321'

the gradle failed because he looking for JAVA_HOME in 'C:\Program Files\Java\jre1.8.0_321' but this directory doesn't exist.

but my JAVA_HOME path is 'C:\Program Files\Java\jdk1.8.0_202' JAVA_HOME

I tried to reinstall java and delete the android directory without any success.

I tried to put JAVA_HOME dir in 'gradle.properties' but still the 'C:\Program Files\Java\jre1.8.0_321' overwritten that.

When I run from the android studio it works, just from 'ionic cap run android' not working.

Ramesh R
  • 7,009
  • 4
  • 25
  • 38

1 Answers1

0

I've found the solution:

  1. Set the right $JAVA_HOME path in .bashrc
  2. go to $HOME directory and delete .gradle folder.
  3. re-gradle your project
Panciz
  • 2,183
  • 2
  • 30
  • 54