Search code examples
androidcordovagradleionic-frameworkcapacitor

Angular 11, Ionic 5 , Capacitor 2 gradle sync error "Caused by: org.gradle.api.resources.MissingResourceException"


I am getting the following error on npx cap open android

Caused by: org.gradle.api.resources.MissingResourceException: Could not read script '/Users/adk/Documents/projectA/node_modules/cordova-androidx-build/src/android/cordova-androidx-build.gradle' as it does not exist.

I have cordova-androidx-build installed and cordova-androidx-build.gradle file is present in node_modules of my project. The node_modules folder has read-write access as well. Any help is much appreciated.


Solution

  • I posted the question after trying for 2 days in vain and within an hour after posting the question, I found the solution. So for all those future seekers, you can follow the following steps to fix it.

    1. Open android studio. (If it's already open, close the project, not android studio)
    2. You will get a list of projects on the left hand side panel, right click on your project(which has issue) and remove the project from the home screen of the android studio
    3. Import the project again in android studio.

    This fixed it mysteriously, no idea how.