EDIT: This project demos the behavior:
https://github.com/NathanielWaggoner/AndroidExamples/tree/master/packing
There is a read me that explains the first time you build it.
I have a set of projects built using Gradle and AndroidStudio. We'll call them Lib1, SDK and APP
. Lib1
and SDK
are deployed to a private Sonotype repo that I maintain.
App
depends on SDK
- App is a normal android project
SDK
depends on Lib1
- SDK is an Android Library Project repackaged as a Jar
Lib1
depends on some Android Stuff. - Lib1
is a normal android library project, packaged as an aar.
When I run gradle dependencies
In each project i see some things i don't expect.
In Lib1
I see all appropriate dependencies, just as I would expect (including dependencies of dependencies)
In SDK
I see all relevant dependencies and their trees except for that of Lib1. In the case of lib1 the only thing I see is lib1, not any of its dependencies.
In APP
i see something very simlar to the SDK
dependencies - I see all dependencies are their trees, except for SDK
. In the case of SDK
I only see the SDK
. I don't see Lib1 listed as a dependency (or any of the other dependencies of SDK
).
Everything builds fine - that is i can compile and deploy Lib1
, and compile and deploy SDK
. I can compile the APP
- however when it uses SDK
code which references Lib1
I get noClassDefFound on the Lib1
classes.
Checking the output jars none of the library classes are included in the Jars created during the build phases of SDK
or Lib1
, and the poms created don't reference any dependencies (from installArchives/uploadArchives tasks).
How do I work around this? I don't want consumers of the SDK
to have to directly compile in the Lib1 in order for those classes to be found.
This topic:
http://forums.gradle.org/gradle/topics/using_the_maven_publish_plugin_no_dependencies_in_pom_xml
shows some extremely similar behavior to what it turns out was happening to me - my poms were being generated without their dependency information being included.
For now i've got this work around in my installArchives.`
task installArchives(type: Upload) {
repositories.mavenInstaller {
configuration = configurations.archives
//configuration = configurations.default
pom.version = "0.0.1-SNAPSHOT"
pom.artifactId = "lib2"
pom.groupId = "waggoner.android.examples"
pom.withXml {
def node = asNode().appendNode('dependencies').appendNode('dependency')
node.appendNode('groupId','waggoner.android.examples')
node.appendNode('artifactId','lib1')
node.appendNode('version','0.0.1-SNAPSHOT')
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.