How can I adapt my build.gradle to change the final basename of the apk(s) ? (without changing the default suffixes)
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Handling ffmpeg library interface change when upgr
Starting with version 1.1.0 of the Android Gradle plugin you have to use
instead of
project.ext.set("archivesBaseName", "yourOtherName")
in yourbuild.gradle
to make it work.You can also rename the sub-project (without renaming the directory), by putting the following in the root
settings.gradle
:On Gradle 1.8,
project.archivesBaseName
does work, but it gives this complaint:To get rid of the warning (and to avoid your build breaking on Gradle 2.0), use this:
...as suggested in the ExtraPropertiesExtension documentation.
Update (Gradle plugin 1.1.0)
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:The below codeworked great for me on v1.3.1 and with APKs only:
Again, this works with android plugin 1.3.1 (not 1.3.0) but we were still having trouble renaming both our apps (APK) and libs (AAR). A big problem since we have a 20+ project setup where we are locking down where deployed binaries come from and not duplicate code in every sub project build.gradle.
The following worked for us:
Define the following method (and plugin) in root build.gradle:
For applications use:
For libraries use:
Now you get some really nice files with a common prefix, project name, git-describe-wth-sha1-buildflavor, and extension.
OLD example:
NEW example:
A bonus is that it doesn't rename the unaligned apks.