AndrWeisR
AndrWeisR

Reputation: 1226

Ionic Android - how do you rename the built output file?

In Ionic 5, doing an Android build with ionic cordova build android produces an output file called app-debug.apk, or app-release.apk. How can I rename that file?

Upvotes: 0

Views: 597

Answers (1)

AndrWeisR
AndrWeisR

Reputation: 1226

  1. Create a file build-extras.gradle somewhere in your Ionic project.
  2. In build-extras.gradle, add the following to set the name of the output file to a property myOutputName:
android  {
    setProperty("archivesBaseName", myOutputName)
}
  1. In config.xml, add the following within <platform name="android">, to make the build use your build-extras.gradle file:
<resource-file src="path/to/build-extras.gradle" target="build-extras.gradle" />
  1. Build the app with command:
ionic cordova build android -- -- --gradleArg=-PmyOutputName=NewFileName

This will produce a file called NewFileName.apk.

Upvotes: 2

Related Questions