library with bundles dependencies (fat aar)

后端 未结 3 974
感情败类
感情败类 2020-12-02 23:08

We build a library that we distribute to our customers. We distribute the raw aar files for them to use. Also we use the raw access API of GitHub to provide a Maven reposito

3条回答
  •  醉话见心
    2020-12-03 00:06

    I simply discourage making android library depending on another android library. There is no official support for bundling android library inside output aar (see: https://stackoverflow.com/a/20715155/2707179) and I don't see it coming in foreseeable future.

    Thus, currently it's easiest to keep all android-related stuff in one module and keep other modules plain java.

    Bundling plain java module is quite easy (just copy output classes or output jar to your android library in gradle) but android modules are much harder. At some point there was a good gradle script https://github.com/adwiv/android-fat-aar. Unfortunately, it's no longer maintained and doesn't work with latest android gradle plugin. And changes in android plugin are not well documentented so creating (and maintaining) your own custom plugin/script would be really painful.

    I really don't understand Android team rationale behind not allowing to embedd one android library into another (apart from "it's complicated"), but with current situation it's just much easier to keep all android stuff in one module.

    Of course modularizing your project is a good idea. I really tried to keep seperate modules, but at some point I had to give up, all these workarounds were just not worth it.

提交回复
热议问题