在gradle中,我想在我的自定义插件中修改android:minSdkVersion
。
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />
我想完成如下。
void apply(Project project) {
File manifest = project.file("${project.buildDir}/intermediates/manifests/full/${projectFlavorName}/${buildTypeName}/AndroidManifest.xml")
def manifestXml = new XmlParser().parse(manifest)
manifestXml.uses-sdk.attribute("android:minSdkVersion") = 20
}
怎么做?
答案 0 :(得分:0)
显示如下:
File Manifest = getManifest()
def manifestXml = new XmlParser().parse(Manifest)
manifestXml."uses-sdk".replaceNode{
'uses-sdk'(' android:minSdkVersion="12"\n' +
' android:targetSdkVersion="14"')
}
def fw=new FileWriter(Manifest.toString())
new XmlNodePrinter(new PrintWriter(fw)).print(manifestXml)