Failed to resolve: project :capacitor-android

Hi There Community,

I am facing the issue with building my ionic capacitor project on android studio.

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:debugCompileClasspath'.
   > Could not resolve project :capacitor-android.
     Required by:
         project :app
      > No matching configuration of project :capacitor-android was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-community-background-geolocation.
     Required by:
         project :app
      > No matching configuration of project :capacitor-community-background-geolocation was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-app.
     Required by:
         project :app
      > No matching configuration of project :capacitor-app was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-browser.
     Required by:
         project :app
      > No matching configuration of project :capacitor-browser was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-camera.
     Required by:
         project :app
      > No matching configuration of project :capacitor-camera was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-device.
     Required by:
         project :app
      > No matching configuration of project :capacitor-device was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-filesystem.
     Required by:
         project :app
      > No matching configuration of project :capacitor-filesystem was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-geolocation.
     Required by:
         project :app
      > No matching configuration of project :capacitor-geolocation was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-haptics.
     Required by:
         project :app
      > No matching configuration of project :capacitor-haptics was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-keyboard.
     Required by:
         project :app
      > No matching configuration of project :capacitor-keyboard was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-network.
     Required by:
         project :app
      > No matching configuration of project :capacitor-network was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-preferences.
     Required by:
         project :app
      > No matching configuration of project :capacitor-preferences was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-splash-screen.
     Required by:
         project :app
      > No matching configuration of project :capacitor-splash-screen was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.
   > Could not resolve project :capacitor-status-bar.
     Required by:
         project :app
      > No matching configuration of project :capacitor-status-bar was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.1' but:
          - None of the consumable configurations have attributes.

This is how the capacitor.settings.gradle file looks like and I see no problems with the paths there.

// DO NOT EDIT THIS FILE! IT IS GENERATED EACH TIME "capacitor update" IS RUN
include ':capacitor-android'
project(':capacitor-android').projectDir = new File('../node_modules/@capacitor/android/capacitor')

include ':capacitor-community-background-geolocation'
project(':capacitor-community-background-geolocation').projectDir = new File('../node_modules/@capacitor-community/background-geolocation/android')

include ':capacitor-app'
project(':capacitor-app').projectDir = new File('../node_modules/@capacitor/app/android')

include ':capacitor-browser'
project(':capacitor-browser').projectDir = new File('../node_modules/@capacitor/browser/android')

include ':capacitor-camera'
project(':capacitor-camera').projectDir = new File('../node_modules/@capacitor/camera/android')

include ':capacitor-device'
project(':capacitor-device').projectDir = new File('../node_modules/@capacitor/device/android')

include ':capacitor-filesystem'
project(':capacitor-filesystem').projectDir = new File('../node_modules/@capacitor/filesystem/android')

include ':capacitor-geolocation'
project(':capacitor-geolocation').projectDir = new File('../node_modules/@capacitor/geolocation/android')

include ':capacitor-haptics'
project(':capacitor-haptics').projectDir = new File('../node_modules/@capacitor/haptics/android')

include ':capacitor-keyboard'
project(':capacitor-keyboard').projectDir = new File('../node_modules/@capacitor/keyboard/android')

include ':capacitor-network'
project(':capacitor-network').projectDir = new File('../node_modules/@capacitor/network/android')

include ':capacitor-preferences'
project(':capacitor-preferences').projectDir = new File('../node_modules/@capacitor/preferences/android')

include ':capacitor-splash-screen'
project(':capacitor-splash-screen').projectDir = new File('../node_modules/@capacitor/splash-screen/android')

include ':capacitor-status-bar'
project(':capacitor-status-bar').projectDir = new File('../node_modules/@capacitor/status-bar/android')

Screenshot below from Android Studio.

I would really appreciate, if I could some guidance fixing this issue. Thank you so much!

what’s your Android Studio version?

Hi Julio,
Here is the version info of My Android Studio.

Android Studio Jellyfish | 2023.3.1
Build #AI-233.14808.21.2331.11709847, built on April 13, 2024
Runtime version: 17.0.10+0-17.0.10b1087.21-11572160 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 14.5
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 8
Metal Rendering is ON
Registry:
ide.experimental.ui=true
Non-Bundled Plugins:
com.github.masahirosuzuka.PhoneGapIntelliJPlugin (233.11799.172)

I have managed to resolve this issue by doing the following steps.

  • Reverted my code base back to capacitor 5.

  • The reverted code base obviously had my android project generated using capacitor 5.

  • Then the project build fine on Android Studio.

  • I then just executed, npm i -D @capacitor/cli@latest and npx cap migrate

  • Now everything worked fine.

  • I think the problem occurred due to some gradle files being deleted accidentally during the capacitor upgrade, I then deleted the android folder and regenerated it using ionic capacitor add android but that didn’t solve the issue.

  • Finally reverting back and upgrading on existing android project folder worked fine.