Ionic Cordova Build Android - CordovaLib:generateDebugRFile FAILED

Hello. I am new to programming on Ionic. I am on Ionic version 5.4.16, and I am trying to build my Ionic Angular app that has been integrated with Cordova for Android. In the terminal in the root of my app, I type ionic cordova build android , but I cannot get my app to build. The app builds up to a certain point, but crashes with the following error:

> Task :CordovaLib:generateDebugRFile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':CordovaLib:generateDebugRFile' (type 'GenerateLibraryRFileTask').
> File 'C:\Projects\MyApp\platforms\android\CordovaLib\build\intermediates\local_only_symbol_list\debug\R-def.txt' specified for property 'localResourcesFile' does not exist.

Any support would be greatly appreciated! Thank you!

Could you please add more detail, like you are having this issue on Linux or Mac machine.

If you are on Mac machine then it may be the issue of gradle version. After updating the gradle, app should build successfully.