所以目前我添加了我的应用程序的快捷方式,但我有两个不同版本的应用程序的两个不同的包名称。在shortcuts.xml中使用$ {applicationId}不起作用,也不使用字符串资源引用。如何指向我的targetPackage指向应用程序中我的productFlavors的不同applicationId?
答案 0 :(得分:3)
如何指向我的targetPackage指向我应用中的productFlavors的不同applicationId?
在每个产品风格的flavorname/src/res/xml/
目录中都有一个不同的快捷方式XML文件。
在shortcuts.xml中使用$ {applicationId}不起作用
目前,这只是清单。
也没有字符串资源引用
理想情况下,这可行,但目前不支持。
答案 1 :(得分:0)
如果要在shortcuts.xml中使用$ {applicationId},可以将以下内容添加到build.gradle中:
android {
applicationVariants.all { variant ->
variant.mergeResources.doLast {
println "Updating shortcuts.xml"
ant.replaceregexp(match: "\\\$\\{applicationId\\}", replace: defaultConfig.applicationId, flags: 'g', byline: true) {
fileset(dir: "${buildDir}/intermediates/res/merged/${variant.dirName}/xml", includes: 'shortcuts.xml')
}
}
}
}