Android的摇篮编译:重命名APK摇篮、重命名、Android、APK

2023-09-05 08:38:29 作者:抹不去记忆的泪、

我如何能适应我的build.gradle改变APK(S)的最终基名? (不改变默认后缀)

How can I adapt my build.gradle to change the final basename of the apk(s) ? (without changing the default suffixes)

推荐答案

在摇篮1.8, project.archivesBaseName 做工作,但它给出了这样的抱怨:

On Gradle 1.8, project.archivesBaseName does work, but it gives this complaint:

创建点播(又名动态特性)特性已   德precated,并计划在摇篮2.0被删除。请阅读   http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html   有关替代的动态属性的信息。德precated   动态属性:archivesBaseName的根项目   MyApp的',值:AnotherName

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".

要摆脱警告(并避免你的构建打破摇篮2.0),使用这样的:

To get rid of the warning (and to avoid your build breaking on Gradle 2.0), use this:

project.ext.set("archivesBaseName", "AnotherName");

...作为ExtraPropertiesExtension文档。

Android的摇篮插件版本1.1.0引入了爆发 archivesBaseName ,as friederbluemle指出。但幸运的是这已被固定(在版本1.1.2 )。

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).