The same happened when I updated Android Studio to the latest version this week. I managed to resolve the issue with the help of a different thread: https://stackoverflow.com/a/79068663.
After updating the com.android.application plugin to version 8.3.2 in the android/settings.gradle file and the gradle distributionUrl to v8.5 in the gradle-wrapper.properties file, it worked fine for me again.