有没有简单可行的办法在AAR里集成导入的AAR

            现在的SDK基本上都会封装成AAR来发布,但是有个问题,如果你的AAR还引用了其它的AAR,导出的时候并不会自动把引用的AAR也集成进去,别人使用你的AAR的时候,还需要再把你引用的AAR再导入一次。

         如果你的SDK再供给其它SDK,这种集成问题就比较蛋疼了。有没有办法把引用的AAR集成到你的AAR里呢。

         有一个比较繁琐的办法,就是把aar包解压,aar里面可能包含了res,AndroidManifest.xml,jni,jar包等,分别把这些手动合并到你的AAR工程里。

         除了这个繁琐的办法,Android Studio有没有提供一个简单可行的办法,自动集成进去呢,google了一圈,在stackoverflow上找到了如下答案:

            There is no mechanism to combine library. It's a bit complicated as you probably want to control which dependencies get merged (for instance you probably don't want to include support-v4 in there). Also you'd need to merge the resources and Android manifest.

At this time there's no way to easily hack something, unless you are sure the resources have no conflicts between the two res folders (for instance you could have strings_a.xml in one lib and strings_b.xml in the other lib). This way you can just "merge" the two res folders by copying them both into the same location (as opposed to do a merge at the android res level).

For the Manifest it'd be more complicated, but doable with some custom code.

Providing a built-in mechanism for this is very low on our priority so don't expect it anytime soon.

        这个答案是一位叫Xavier Ducrohet提供的

        他的资料里这么写的:Android SDK Tech Lead - Google Inc.

        看来是一个比较官方的答案了

        所以结论是,目前并没有一个简单可行的方法来实现这样的功能。:(


猜你喜欢

转载自blog.csdn.net/justFWD/article/details/51819197