通过如下步骤:
1
最后一行
2
3
4
preBuild {
doLast {
def imlFile = file(project.name + ".iml")
println('Change ' + project.name + '.iml order')
try {
def parsedXml = (new XmlParser()).parse(imlFile)
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
parsedXml.component[1].remove(jdkNode)
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
new groovy.util.Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
} catch (FileNotFoundException e) {
// nop, iml not found
}
}
}
5
6
Proguard
-ignorewarnings
7
如果没有配置android环境变量,混淆文件还是选择绝对路径