A problem occurred configuring project ':capacitor-android'. in Android Studio

Could not read build file ‘…/node_modules/@capacitor/android/capacitor/build.gradle’ as it does not exist.
*Try:
Run with --info or --debug option to get more log output.
Run with --scan to get full insights.
Get more help at https://help.gradle.org.

I followed all the steps to build a capacitor project in android studio:

npm run build
npx cap add android
npx cap sync
npx cap open android

I have pointed to the path of jdk 17 in android studio since capacitor is using gradle 8.2.1.

Did you check to see if that file exists? Trying running npm update.

@twestrick Yes the file exists. I ran npm update and repeated the sync process but it didn’t get resolved. I tried checking with grade 8.9 and jdk 21 as well. Funnily I was able to build and generate an apk file a couple of days back.

Try going through the steps outlined in these docs to clean and invalidate the cache - Troubleshooting Android Issues | Capacitor Documentation