Transitive dependencies not resolved for aar library using gradle
I have solved my problem by setting transitive
attribute for my aar dependency:
compile ('com.somepackage:LIBRARY_NAME:1.0.0@aar'){
transitive=true
}
Can an AAR include transitive dependencies?
It took a little while but I found what I was looking for. It just happened to be the way I was wording my searches.
This lesser-seen answer was exactly what I was looking for:
Transitive dependencies not resolved for aar library using gradle
Note that dependencies are only associated with aar libraries if they are hosted in a maven repository, in the first place, as the pom file is not included in the aar.
Essentially, I needed to add a
transitive = true
...to the build.gradle
of Bar
Example:
compile ('com.foo:FOO:1.0.0@aar'){
transitive=true
}
This way it includes all of my transitive libraries.
Note, however, that this may actually cause conflicts between dependencies (especially local ones) which can be resolved using an exclude
tag.
Transitive dependencies for local aar library
The aar file doesn't contain the nested (or transitive) dependencies and doesn't have a pom file which describes the dependencies used by the library.
It means that, if you are importing a aar file using a flatDir
repo you have to specify the dependencies also in your project.
In your case adding transitive=true
doesn't resolve your issue for the reason described above.
You should use a maven repository (you have to publish the library in a private or public maven repo), you will not have the same issue.
In this case, gradle downloads the dependencies using the pom file which will contains the dependencies list.
Error building Android library: Direct local .aar file dependencies are not supported
I recently encountered the same issue, the fix was to remove the library from libs/
and import it using File -> New -> New Module -> Import .JAR/.AAR Package
, then referencing it in the library module build.gradle
file:
dependencies {
implementation project(":imported_aar_module")
}
If you are on a newer Android Studio version (4.0.0+), this option is not available. Instead you have to do it manually.
- Create a new directory and put the following content into the
build.gradle
file withing the new directory:
configurations.maybeCreate("default")
artifacts.add("default", file('[nameOfTheAar].aar'))
- Place the
aar
into this new directoy. Next to thebuild.gradle
file. - Add the new created Gradle project to the
settings.gradle
file:
include(":pathToTheCreatedDirectory")
- Include the project in your library where you want to use the
aar
:
implementation project(":pathToTheCreatedDirectory", configuration = "default")
How to set transitive = true for local .aar library?
It is not possible to download transitive dependencies with a local aar file.
This file does not contains a pom.xml
which reference all dependencies linked to this library, so adding transitive = true
will do simply nothing.
If Cuckoo library is not hosted in a Maven repository, I'm afraid you will be obliged to load them manually in your build.gradle
.
Gradle - Android - 2 Libraries dependency conflict
try this:
implementation(Lib A){
exclude module : 'lib c'
}
Related Topics
Findviewbyid Returns Null in a Dialog
Android-Java- How to Sort a List of Objects by a Certain Value Within the Object
Can the Android Sdk Work with Jdk 1.7
Start a Jar File Like Service in Linux
Java 8: Performance of Streams VS Collections
Tracing Xml Request/Responses with Jax-Ws
Why Is the Catch(Exception) Almost Always a Bad Idea
How to Convert a Map to List in Java
Date Object Simpledateformat Not Parsing Timestamp String Correctly in Java (Android) Environment
Gson - Convert from JSON to a Typed Arraylist<T>
Running Shell Commands Though Java Code on Android
How to Debug Java -Jni Using Gdb on Linux
Integrating Tomcat and Eclipse as a Hot-Deploy Environment
What Does Statement.Setfetchsize(Nsize) Method Really Do in SQL Server Jdbc Driver