首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >接口'variantOutput.getProcessManifest()‘已过时

接口'variantOutput.getProcessManifest()‘已过时
EN

Stack Overflow用户
提问于 2019-02-21 13:57:57
回答 1查看 1.6K关注 0票数 3

我正在尝试更改版本代码、版本名称和应用程序图标。下面是我的代码

代码语言:javascript
复制
    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"
    }

收到以下警告:警告:'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

EN

回答 1

Stack Overflow用户

发布于 2019-05-27 18:43:48

更改以下内容

代码语言:javascript
复制
output.processManifest.doLast {
    //your code
}

使用

代码语言:javascript
复制
output.getProcessManifestProvider().get().doLast {
    //your code
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54800198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档