First, state that there are several reasons for this error
Here are my personal solutions to this error:
1. First, find gradle Properties file, open
2. Write “Android” in the space After enableaapt2 = false, click sync now
3. Errors will occur after synchronization. Don’t worry. Delete what you wrote and synchronize again
There is no problem running after resynchronization (personal situation)