有沒有簡單可行的辦法在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.
他的資料裡這麼寫的:Android SDK Tech Lead - Google Inc.
看來是一個比較官方的答案了
所以結論是,目前並沒有一個簡單可行的方法來實現這樣的功能。:(