public.xml用來告訴aapt保持固定的資源ID
res/values/pulibc.xml
<resources>
? ? <public id = "0x7f050011" name = "a_in" type = "anim"/>
<resources/>
android gradle plugin 從1.3.0開始忽略了public.xml 盈匾,不過可以通過gradle腳本來繞過這個限制。
afterEvaluate {
for(variantinandroid.applicationVariants) {
defscope = variant.getVariantData().getScope()
String mergeTaskName = scope.getMergeResourcesTask().name
defmergeTask =tasks.getByName(mergeTaskName)
mergeTask.doLast {
copy {
inti=0
from(android.sourceSets.main.res.srcDirs) {
include'values/public.xml'
rename'public.xml', (i++ ==0?"public.xml":"public_${i}.xml")
}
into(mergeTask.outputDir)
}
}
}
##END