From the error message, it looks like you are trying to use Gradle 9.
Capacitor 3 uses Gradle 7 (source) so you probably need to downgrade.
In Android Studio go to:
- File → Project Structure… → Project
Then change Gradle Version to 7.0 and Android Gradle Plugin Version to 4.2.0.