Enable AAR dependency in Android library project

In my Android Studio Gradle project, I use several libraries, while one library should use the local AAR file as a dependency. I used a popular solution to include an AAR file depending on my library project:

flatDir { dirs 'libs' } compile(name: 'aar-library', ext: 'aar') 

When I try to sync now, I get an error

Failed to solve: dependency 'aar-library'

in my main project, even if I am not using / not referencing the AAR file. If I just copy the AAR file to the libs folder of my main project, it works too. Any idea?

+5
source share
3 answers

A solution has already been found. It seems that the AAR dependencies are all moving together, so the main project is trying to resolve the AAR dependency in its "libs" directory, where it clearly does not exist. What you need to do is more accurately determine where each module, which depends on the library with the AAR file, can find it relative to its path, for example.

dirs project(':my-library-project').file('libs')

+10
source

I worked like this:

 compile 'com.example.lib:lib_name: 1.0.0@aar ' 

In this example, lib_name:1.0.0.aar is the name of the file.

0
source

If user response 1033552 does not work. In my case, this did not work.

Below were the steps for me.

  • Right-click project → New → Module → Import aar package → select a file and import it.
  • In settings.gradle , Depends on dependencies. example include ':imported-aar', ':your-library', ':app'
  • Now build.gradle your library add compile project(':imported-aar')
0
source

All Articles