Android Maven打包批量替換資源檔(overlay換皮膚)&AAR打包相依模組覆蓋策略

來源:互聯網
上載者:User

標籤:overlay   android開發   android   maven   

1.AAR打包覆蓋

主module(APK)會將AAR中同名資源覆蓋:

策略如下:

資源檔例片,layout是採用覆蓋方式。values檔案例如strings.xml是採用合并方式。
有依賴的模組只能採用aar進行打包,例如ui庫等二方庫。建議將所有模組共同的resource資源放到通用module中,並且建立相應的命名機制,防重複。
以後如有業務獨立的模組可以打成bundle,bundle可以看成一個獨立的apk,擁有獨立的資源檔
2. maven支援編譯時間指定res目錄,(和Android overlay類似)。具體如下:

                 <artifactId>android-maven-plugin</artifactId>                  <configuration>+                    <resourceOverlayDirectories>+                        <dir>res-overlay</dir>+                    </resourceOverlayDirectories>

在android maven-plugin的configuration節點添加resourceOverlaytDirectioies節點,設定overlay目錄。

打包時res-overlay會替換res下的同名資源檔。

可以用來換皮膚,替換不同版本資源檔等。



參考:

https://code.google.com/p/maven-android-plugin/wiki/ApkSourcesDependency

https://code.google.com/p/maven-android-plugin/wiki/Changelog

Android Overlay:

http://my.oschina.net/kingguary/blog/160190

Android Maven打包批量替換資源檔(overlay換皮膚)&AAR打包相依模組覆蓋策略

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.