A scenario
Ionic project used to run fine, today I compile Android suddenly the following error.
A problem occured configuring project ':capacitor android'.
> Could not read build file '/Users/ado/my/work/h5/ionic_demo/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 insigns.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occured configuring project ':capacitor android'.<1111 internal calls>
Caused by: org.gradle.api.resource.MissingResourceException: Could not read build file '/Users/ado/my/work/h5/ionic_demo/node_modules/@capacitor/android/capacitor/build.gradle'as it does not exist. ... 107 moreCopy the code
The solution
First check whether the Build. gradle of the Android module in node_module exists. If it does, you can only regenerate it.
- Delete the @Capacitor dependency library in node_module.
- Using the command
npm install @capacitor/core @capacitor/cli
Generate the @capacitor directory - Close the project in Android Studio and return to the Welcome screen. Remove the Project from the list on the left, then click Open an Existing Project on the right to reopen the Project and compile again to recognize build.gralde as normal.