Reputation: 83
The Android library is hosted in a private Maven Artifactory repo in the company that I'm working in. This library is using okhttp as a one of the dependencies.
In the application project I import this library as such:
compile 'com.domain.artifact:myartifact:1.0.0@aar'
The library is imported, however when I call the API in the library, the application crashes with ClassNotFoundException due to missing okhttp classes.
Doing a gradle command to print dependencies shows that the application project does not download any of the library's dependency (including okhttp)
+--- com.domain.artifact:myartifact:1.0.0
\--- com.android.support:appcompat-v7:25.0.1
\--- com.android.support:support-v4:25.0.1
+--- com.android.support:support-compat:25.0.1
| \--- com.android.support:support-annotations:25.0.1
+--- com.android.support:support-media-compat:25.0.1
| \--- com.android.support:support-compat:25.0.1 (*)
+--- com.android.support:support-core-utils:25.0.1
| \--- com.android.support:support-compat:25.0.1 (*)
\--- com.android.support:support-core-ui:25.0.1
How can I ensure that the library's dependencies are also downloaded or published successfully?
====== Additional Info =======
The library is published with "maven-publish" plugin, and dependency is added using "pom.withXml" in the gradle script, and okhttp is in the POM file of the library.
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
Upvotes: 2
Views: 687
Reputation: 364005
You are using the @aar
notation in your dependency.
It means that you want to download only the aar artifact excluding all nested dependencies.
You can check this part of documentation:
Check the Artifact only notation
section:
An artifact only notation creates a module dependency which downloads only the artifact file with the specified extension. Existing module descriptors are ignored.
Using the @aar
notation if you want to download the dependencies, you should add transitive=true
.
I'd expect that omitting @aar it should work.
Upvotes: 3