android - API 'variantOutput.getProcessManifest()' 已过时
问题描述
我正在尝试更改版本代码、版本名称和应用程序图标。下面是我的代码
variant.outputs.all { output ->
def newApkName
if (output.zipAlign) {
newApkName = "Application.apk"
}
output.processManifest.doLast{
// Stores the path to the maifest.
String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"
// Stores the contents of the manifest.
def manifestContent = file(manifestPath).getText()
// Changes the version code in the stored text.
manifestContent = manifestContent.replace('android:versionName="dev_build"',
String.format('android:versionName="%s"', variant.versionName))
// Overwrites the manifest with the new text.
file(manifestPath).write(manifestContent)
}
output.processManifest.doLast{
// Stores the path to the maifest.
String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"
// Stores the contents of the manifest.
def manifestContent = file(manifestPath).getText()
// Changes the version code in the stored text.
manifestContent = manifestContent.replace('android:icon="@drawable/app_icon_main"',
String.format('android:icon="@drawable/%s"', getVersionIconName()))
// Overwrites the manifest with the new text.
file(manifestPath).write(manifestContent)
}
outputFileName = "Application.apk"
}
收到以下警告:警告:API 'variantOutput.getProcessManifest()' 已过时,已替换为'variantOutput.getProcessManifestProvider()'。它将在 2019 年底被删除。有关更多信息,请参阅https://d.android.com/r/tools/task-configuration-avoidance。要确定调用 variantOutput.getProcessManifest() 的内容,请在命令行上使用 -Pandroid.debug.obsoleteApi=true 以显示堆栈跟踪。受影响的模块:应用程序
环境详细信息:Android Studio:3.3.1 Gradle 版本:4.10.0 构建工具版本 28.0.2
解决方案
更改以下内容
output.processManifest.doLast {
//your code
}
和
output.getProcessManifestProvider().get().doLast {
//your code
}
推荐阅读
- python - 如何消除python列表中的项目
- c++ - 如何改进我的“字符串”对象比较功能
- alfresco - 我如何在 APS/activiti 中使用子进程
- ios - 如何在 SWIFT3 XCODE 8.2 的 IOS 应用程序中显示 Snackbar 的操作中的特定视图
- spring - 通过 PagingAndSortingRepository 对 Spring Data Rest 中的 @Transient 列进行排序
- android - Single.concat报错继续下一个
- fonts - 如何知道特定字体样式中特定字符的宽度?
- sql - 工会没有给出预期的结果,而操作员呢?
- autocomplete - pycham自动完成没有做它的工作
- php - 设置 PHP 和 SQL 网站