Android自定义资源id——有效,详细

附件下载 - 含测试工程

最新AndroidStudio可用(3.0.1 - 2018年2月26日14时49分21秒)
1
2

//补充步骤二中的代码 - public-xml.gradle
afterEvaluate {
    for (variant in android.applicationVariants) {
        def scope = variant.getVariantData().getScope()
        String mergeTaskName = scope.getMergeResourcesTask().name
        def mergeTask = tasks.getByName(mergeTaskName)

        mergeTask.doLast {
            copy {
                int i = 0
                from(android.sourceSets.main.res.srcDirs) {
                    include 'values/public.xml'
                    rename 'public.xml', (i == 0 ? "public.xml" : "public_${i}.xml")
                    i++
                }
                into(mergeTask.outputDir)
            }
        }
    }
}

3

apply from: 'public-xml.gradle'

4
5

android.enableAapt2=false

6
7
8
9
10
11
12
13
14

发布了77 篇原创文章 · 获赞 44 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/lemisky/article/details/79377242
今日推荐