1

I am working on writing an SDK for a client. Part of the SDK requires me to interface with a good 20-30 endpoints. How I have always done this in the past is simply used Retrofit and OkHttp for the API interface. I recently discovered, however, that you cannot use 'nested' library references within a library.

My question is, how do I go about using Retrofit in this current library I am making so that it can be used on other devices? Do I just need to clone the repo, copy the code into my project and go from there? Or is there a simpler method?

Thanks all.

Community
  • 1
  • 1
PGMacDesign
  • 6,092
  • 8
  • 41
  • 78

1 Answers1

2

Your can use maven transitive dependency.

Or AAR have no problems with nested jar files. From documentation

A library module can include a JAR library

You can develop a library module that itself includes a JAR library; however you need to manually edit the dependent app modules's build path and add a path to the JAR file.

I use this approach for okhttp.

Community
  • 1
  • 1
Dmitrii Nechepurenko
  • 1,414
  • 1
  • 11
  • 13
  • Solid advice! I'll update with which one worked for me once I get it working. Thanks for the help Dmitrii. – PGMacDesign Nov 16 '16 at 16:47
  • So, I seem to be having problems with both. With Mavin transitive, I have the transitive=true setup, but I keep getting an error that multiple dex files define said library (I have no other libraries...). With AAR nested jar files, I go into the manifest to write the uses-library code and it will never compile, indicating that it is missing the jar file (when the jar file is in the libs directory). Any idea as how to solve either of those problems? – PGMacDesign Nov 16 '16 at 18:04
  • About jar - you need add it to gradle.The esaiest is(if you use android studio) right click on file -> add as library. or add this line to gradle: `compile files('libs/nested_library.jar')` – Dmitrii Nechepurenko Nov 17 '16 at 03:05
  • About maven - I cannot test it now but I think that this problem is solved by using "exclude" in gradle – Dmitrii Nechepurenko Nov 17 '16 at 03:10