There are a few questions floating around regarding transitive dependencies with AAR files in Gradle:
- Android Studio 0.2.3 cannot resolve transitive aar dependencies
- Android Gradle library dependency with library dependency using Nexus
- Aar in repository. External dependency and NoClassDefFoundError
I too have run into similar problems trying to set up transitive dependencies upon AAR files in a remote repository. I have App A, depending upon Library B, which in turn depends
upon Library C. Library C is in a Maven repo. Library B is in the same repo, with a POM
that contains the dependency upon Library C. App A has Library B in its dependencies. However, running gradle clean assembleDebug
results in: "Module version [Library B] depends on libraries but is not a library itself".
I tried putting a bounty on one of those questions, hoping for clarity, with no luck.
My guess is that there are two possible sources of the difficulty that I and those with the aforementioned SO question are seeing:
Transitive AAR dependencies from a remote repository are simply broken
Transitive AAR dependencies from a remote repository work, but there is something off in our POM files,
build.gradle
files, or something that is breaking the dependencies
The Question: Does anyone know of an AAR artifact in some public repository (e.g., Maven Central), that depends upon another AAR artifact, also in the same public repository?
I am not interested in an AAR that depends upon something in a local repository, like an AAR in Maven Central that depends upon com.android.support:support-v4
. In my case, if Library B and Library C are both in my local Maven repository (~/.m2
), everything works fine.
According to Xav, what I am doing should work. Hence, I am hoping that somebody can point me to a working example, so that I can use it to determine where the rest of us may be going wrong.
NOTE: I know that asking for off-site resources is verboten. In this case, I am not looking for the resource in its own right, but as an example of a working configuration, to help debug a non-working configuration. If you have another way of writing up an answer showing a working configuration, that'd be awesome!
Thanks!
It appears that my problem has cleared up with Gradle 1.9 and
com.android.tools.build:gradle:0.7.+
. Leastways, I can no longer reproduce the problem.Starting from Android Studio 0.4.4 using .AAR dependencies is as straightforward as using .JAR dependencies. Just put it into
\libs
directory and reference it inbuild.gradle
:I don't have a public example but I have this scenario successfully setup in a internally-hosted Nexus repository. Here is the setup:
App - Android application project LibraryB - Android library project picasso - Open source library from Square (available on Maven Central) LibraryA - Android library project
App depends on LibraryB and picasso LibraryB depends on LibraryA
Here is the POM for LibraryB (downloaded from Nexus)
Here is the build.gradle for LibraryB
Here is the POM for LibraryA (downloaded from Nexus)
The build.gradle for LibraryA is very similar to the one for LibraryB above.
The artifacts and POM for LibraryA and LibraryB were uploaded via the following Gradle command
The build.gradle for App looks like this
If you need any further information let me know.