“Could not resolve all files for configuration ':app:debugRuntimeClasspath'” when using local library

I have an Android library project with the following structure:

  • android
    • (contains an .aar oh a third party library)
  • example

The point is that from the example project is consumed the library that I have defined in the first level. From the example project, I’m able to use the depedencies of my library, but when trying to compile the example project I’m getting an error like:

    Execution failed for task ':app:checkDebugAarMetadata'.
    > Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
       > Could not find :CustomNameOfTheLibrary:.
         Required by:
             project :app > project :NameOfMyLibraryModule
    Possible solution:
     - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

Where CustomNameOfTheLibrary is the name of the .aar I have imported in my library and NameOfMyLibraryModule if the name of my library.

This happened after upgrading gradle from my library from

'com.android.tools.build:gradle:3.2.1' to com.android.tools.build:gradle:4.1.3'

I also had to stop using

api fileTree(include: ['*.jar','*.aar'], dir: 'libs')

and replace it for

api(name: 'CustomNameOfTheLibrary', ext: 'aar')

Due to obtaining this error:

[Error building Android library: Direct local .aar file dependencies are not supported][1]

Also upgrading gradle from

6.3 to 6.5

And even though I’ve tried to set the same gradle and android plugin version in the example project I’m getting that error.

Any ideas of how could I solve this?