How can I generate R.java from this Error

I have tried severally to clean and rebuild project, but Android studio keeps giving me this error message. (Screenshots are below).
From the event log, it seems my android studio network isn’t able to connect to the URL to download the aapt2 tool. I have also tried changing the proxy network to auto-select but anytime I rebuid project my network fails to parse to host (the host name was set manually by me after installing android studio, I have now done autmatically connect to proxy),


I will be waiting on you guys for a possible solution.
Thanks.

It seems you are building from the commandline using ./gradlew tasks or gradlew.bat tasks
Are you able to share a stacktrace or have you resolved this issue?
Running the following commands from the root folder of your project should provide a stacktrace.
./gradlew --stacktrace tasks or gradlew.bat --stacktrace tasks