Namespace not specified error after Capacitor upgrade

I have recently upgraded my Capacitor version to v6 and Gradle to v8.7, which has introduced a persistent namespace issue. The problem originates from the following path: node_modules/@capacitor/android/capacitor/build.gradle.

Here is the full error message:

Namespace not specified. Specify a namespace in the module's build file:/node_modules/@capacitor/android/capacitor/build.gradle. See https://d.android.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.

If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android.com/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.

Steps I’ve taken so far include modifying the build.gradle files within both the app and android directories using the Android Upgrade Assistant.

I added the namespace in the build.gradle file located in the app directory and ensured that the AndroidManifest.xml file correctly declares the package.

I also removed the package-lock.json file, the node_modules directory, and the android folder, followed by reinstalling everything. However, the issue persists.

Doesn’t look like you updated to Capacitor 6 correctly, Capacitor uses the namespace since version 5.

Doublecheck that the installed @capacitor/android npm package is on version 6.x