How can I adapt my build.gradle to change the final basename of the apk(s) ? (without changing the default suffixes)
Navigate to the folder in which your apk is present. In that folder select your APK file. Right-click on it and click on rename option to rename your APK file.
If anyone is looking to change apk name outside the Android studio(just to send this file to someone else, as in my case), just right click the app name and change it to whatever you want.
Gradle is an automated build system used by Android Studio to build your apps. Gradle handles installing your app on a device.
The Android Gradle plugin (AGP) is the official build system for Android applications. It includes support for compiling many different types of sources and linking them together into an application that you can run on a physical Android device or an emulator.
On Gradle 1.8, project.archivesBaseName
does work, but it gives this complaint:
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties. Deprecated dynamic property: "archivesBaseName" on "root project 'myapp'", value: "AnotherName".
To get rid of the warning (and to avoid your build breaking on Gradle 2.0), use this:
project.ext.set("archivesBaseName", "AnotherName");
...as suggested in the ExtraPropertiesExtension documentation.
Android Gradle plugin version 1.1.0 introduced a bug which broke archivesBaseName
, as friederbluemle noted. But fortunately this has since been fixed (in version 1.1.2).
I found a very simple solution. The apk base name is the property archivesBaseName
defined on the project. So the following line is enough to rename the apks:
project.archivesBaseName = "AnotherName";
Starting with version 1.1.0 of the Android Gradle plugin you have to use
archivesBaseName = "yourOtherName"
instead of project.ext.set("archivesBaseName", "yourOtherName")
in your build.gradle
to make it work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With