As you may have already found, this error can be visible due to many reasons. Hence you need to find actual reason behind the error.
Instead of issuing just;
ionic build android
Navigate to platform android folder; normally located in below path
cd [your_project_folder]\platform\android
And issue below command;
gradlew.bat --info build clean
This will list the actual issue, rectify that and redo the build.
Hope this is helpful!