android - android Gradle流程清单与新的清单合并

  显示原文与译文双语对照的内容

applicationVariants.all { variant ->


 variant.processManifest.doLast {


 println("configuring AndroidManifest.xml removing READ_CALL_LOG");



 def manifestFile = new File("${buildDir}/intermediates/manifests/${variant.dirName}/AndroidManifest.xml")


 def content = manifestFile.getText()


 def updatedContent = content.replaceAll("<android:uses-permission android:name="android.permission.READ_CALL_LOG"/>","")


 manifestFile.write(updatedContent)


 }


 variant.processResources.manifestFile = new File("${buildDir}/intermediates/manifests/${variant.dirName}/AndroidManifest.xml")



}



我尝试了类似这样的东西,但它


 applicationVariants.all { variant ->


 variant.outputs.each { output ->


 def manifestOutFile = output.processManifest.manifestOutputFile


 def newFileContents = manifestOutFile.getText('UTF-8').replace("<android:uses-permission android:name="android.permission.READ_CALL_LOG"/>","")


 manifestOutFile.write(newFileContents, 'UTF-8')


 }


 }



我如何才能在新的合并中实现同样的效果?

预先 Thansk 。

时间: 原作者:


applicationVariants.all { variant ->


 variant.outputs.each { output ->


 output.processManifest.doLast{


 def manifestOutFile = output.processManifest.manifestOutputFile


 def newFileContents = manifestOutFile.getText('UTF-8').replace("<android:uses-permission android:name="android.permission.READ_CALL_LOG"/>","")


 manifestOutFile.write(newFileContents, 'UTF-8')


 }


 }


}



这可以帮助你轻松。

...