17

I am trying to build an aar file with gradle that has remote dependencies. An example build script is below. As you can see I have two dependencies. The problem I'm having is when I do a release, the aar file does not contain the remote dependencies, so when I include the aar file in other projects I get NoClassDefFound errors.

I found that if I copy the jar from my local maven repo to a libs folder in my project, then the jar does get included in the release aar. How do I include the remote dependencies in the aar file? I've also read elsewhere that it's bad practice to ship dependencies like this, so if there's a better way to do what I'm trying to do I'm all for it.

buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.9.+' } } apply plugin: 'android-library' repositories { mavenCentral() mavenLocal() } android { ... omitted for brevity } dependencies { compile 'com.somepackage:someartifact:1.0' compile 'com.anotherpackage:artifact:2.0' } 
2
  • Hi @fxfilmxf, any proceedings here? Best Commented Oct 10, 2016 at 12:19
  • any progress ? i am looking around fro solution but cant find any .. :/ Commented Nov 26, 2018 at 10:17

2 Answers 2

7

try using the transitive attribute:

compile ('group_id:artifact_id:version_name@aar'){ transitive = true } 
Sign up to request clarification or add additional context in comments.

Comments

1

you can check this link:

Transitive dependencies not resolved for aar library using gradle

you have to create a POM file as follows:

<?xml version="1.0" encoding="UTF-8"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <groupId>com.sprezzat</groupId> <artifactId>app</artifactId> <version>1.0.0</version> <packaging>aar</packaging> <dependencies> <dependency> <groupId>com.bugsense.trace</groupId> <artifactId>bugsense</artifactId> <version>3.6</version> <scope>compile</scope> </dependency> </dependencies> </project> 

and deploy it on maven.

After that, you can define it in your android application build.gradle config like this:

compile ('com.somepackage:LIBRARY_NAME:1.0.0@aar'){ transitive=true } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.