In my Case: I have put the correct path for Android and java but still getting the error.
The problem was that I have added the Android platform using sudo command.sudo ionic cordova platform android
.
To solve my problem: First I have removed the platform android by running command
sudo ionic cordova platform rm android
then add the android platform again with out sudoionic cordova platform add android
but i get the error of permissions.
To resolve the error run command
sudo chmod -R 777 {Path-of-your-project}
in my case sudo chmod -R 777 ~/codebase/IonicProject
Then run command
ionic cordova platform add android
or
ionic cordova run android