3

I developed an android SDK to consume our restful API. I used third party libraries like retrofit2 and rxandroid in my SDK.

dependencies 
{
    compile 'io.reactivex:rxandroid:1.2.1'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
}

I released an aar file to my customer. His app imported my aar file and direct used my service which is implemented by retrofit2 to consume APIs. The problem is that his app also needs to include retrofit2 and rxandroid dependencies in his dependencies section. Is there any way letting my customer direct use my service without adding dependencies in his dependencies section? because I don't want my customer know which libraries I used in my SDK.

Thanks in advance.

CMedina
  • 4,034
  • 3
  • 24
  • 39
user3034559
  • 1,259
  • 2
  • 15
  • 31

1 Answers1

1

As far as I know you cannot include aars inside an aar. They don't have configuration files that state what dependencies they need. You can either

  1. Strip the source code from the libraries you are using and compile it with your aar

  2. Consider uploading to bintray or Maven Central Repository

Number two is more preferable since this way all your client will only have to include a link such as compile 'com.abc.efg:version' to grab all the dependencies. It is also a much better option because there are ways of dealing with version conflicts (ex. with exclude group).

Imagine if your client was using another sdk which was pulling in a different version of retrofit. If your aar was given to them via the first method, they won't even be able to build the project at all due to version conflicts. However with the second version, they can simply do

compile ('com.abc.efg:version') { exclude group: 'com.squareup.retrofit2' }

and be free from all that headache. A real life example is Facebook's SDK. It pulls in google's play-services, but people often already include that as a dependency for their project and run into problems like this.

Community
  • 1
  • 1
Bill
  • 4,506
  • 2
  • 18
  • 29