Reputation: 41
I am trying to change version code, version name and app icon. Below is my code
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"
}
Getting bellow warning: WARNING: API 'variantOutput.getProcessManifest()' is obsolete and has been replaced with 'variantOutput.getProcessManifestProvider()'. It will be removed at the end of 2019. For more information, see https://d.android.com/r/tools/task-configuration-avoidance. To determine what is calling variantOutput.getProcessManifest(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Affected Modules: Application
Environment Details: Android Studio : 3.3.1 Gradle Version: 4.10.0 Build Tool Version 28.0.2
Upvotes: 3
Views: 2225
Reputation: 9062
Change the following
output.processManifest.doLast {
//your code
}
with
output.getProcessManifestProvider().get().doLast {
//your code
}
Upvotes: 1