I’m encountering an issue when opening VSCode to work on my Capacitor project with Angular and Ionic. Every time I open VSCode, I get the following error:
error
Project android: A problem occurred configuring root project ‘android’. A problem occurred evaluating root project ‘android’. Project with path ‘:capacitor-android’ could not be found in root project ‘android’.: A problem occurred configuring root project ‘android’. A problem occurred evaluating root project ‘android’. Project with path ‘:capacitor-android’ could not be found in root project ‘android’
my build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.google.gms:google-services:4.4.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply from: "variables.gradle"
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle:
apply plugin: 'com.android.application'
android {
namespace "br.com.company"
compileSdk rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "br.com.company"
minSdkVersion 24
targetSdkVersion 34
versionCode 31
versionName "1.0.12"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
Steps to Reproduce:
1. Open VSCode.
2. Observe the error message appearing.
Troubleshooting Efforts:
• I’ve reviewed the build.gradle configurations and verified the correctness of the file paths and dependencies.
• I’ve ensured that the versions of all tools and libraries are compatible.
Can someone help me identify the cause of this error? Is it related to the Gradle configuration, or could it be something else in the project? Any suggestions on how to diagnose and fix this issue would be greatly appreciated.