覆盖 Android 库项目资产文件

Overriding an Android library project asset file

基于以下链接:

Best practice: Extending or overriding an Android library project class

https://developer.android.com/studio/write/add-resources.html#resource_merging

类 和 Android 库 (AAR) 中的资源是可覆盖的。如何覆盖资产文件?在我的 AAR 文件中,我有一个名为 first.xml 的资产。我想在我的 android 项目中创建我自己的 first.xml 来覆盖我的 AAR 中的文件。我该怎么做?

这是我的测试结果。

这是我在 AAR 中的资产/:

-assets/
 -a.xml
 -b.xml

这是我的 android 项目中的资产/,它依赖于上面的 AAR:

-assets/
 -b.xml
 -c.xml

我的 APK 中生成的资产/如下:

-assets/
 -a.xml (from AAR)
 -b.xml (from my project)
 -c.xml (from my project)