【发布时间】:2019-07-14 23:03:38
【问题描述】:
我正在尝试更改版本代码、版本名称和应用图标。下面是我的代码
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 以显示堆栈跟踪。 受影响的模块:应用程序
环境细节: 安卓工作室:3.3.1 摇篮版本:4.10.0 构建工具版本 28.0.2
【问题讨论】:
-
所以改变方法调用
-
我已经在更改方法名称并得到以下错误后尝试过。错误:无法获取 com.android.build.gradle.internal 类型的 ApkvariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=devDebug, filters=[], versionCode=1000, versionName=dev_build}} 的未知属性“ProcessManifestProvider” .api.ApkVariantOutputImpl.
-
@SatyamGarg ,运气好吗?
标签: android gradle android-gradle-plugin gradlew