如何在新的applicationID中的build.gradle工作? [英] How does the new applicationId in build.gradle work?

查看:454
本文介绍了如何在新的applicationID中的build.gradle工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌发布了Android摇篮插件的0.11版本。

Google released version 0.11 of the Android Gradle plugin.

本发行说明包含以下内容:

The release notes contains the following:

一在0.11的用户可见的变化是,我们已经去precated的
  的packageName和packageNameSuffix设置,并将它们重新命名为
  的applicationID和applicationIdSuffix。这样做的目的是使
  明确指出,这个应用程序ID从包中分离
  在您的清单的声明,并且特别地,R类和
  BuildConfig类和应用内的所有的实现类,
  可以重命名和重构自如;你只需要保持
  applicationID执行相同。如果你打开​​你的build.gradle文件,棉绒
  这些突出德precated电话,并提供快速修复更新
  其中:

One of the user visible changes in 0.11 is that we've deprecated the packageName and packageNameSuffix settings, and have renamed them to applicationId and applicationIdSuffix. The purpose of this is to make it clear that this application id is decoupled from package declarations in your manifest, and in particular, the R class and the BuildConfig class, and all the implementation classes inside your app, can be renamed and refactored freely; you just need to keep applicationId the same. If you open your build.gradle file, lint is highlighting these deprecated calls and offering quickfixes to update them:

这究竟意思。如何从一个在清单?

What exactly does this mean. How is the packagename in the build script decoupled from the one in the manifest?

推荐答案

在AndroidManifest.xml中指定识别设备上安装的一个应用程序。因为人们可能认为,重构Java类,可能需要重命名物业以及物业本身的名称是一种误导。 属性可以在Javadoc中描述的任何字符串尊重限制。

package specified in AndroidManifest.xml identify one application installed on the device. The name of the property itself is misleading because one may think that refactoring java classes may require renaming package property as well. package property can be any string respecting limitation described in javadoc.

由于这种混乱谷歌家伙决定重新命名的applicationID 。然而,这一变化仅适用于摇篮文件。舱单更改属性的名称将打破以previous版本的兼容性,这是我的猜测。

Because this confusion Google guys decided to rename package to applicationId. However, this change apply to gradle file only. Changing manifest property name would break compatibility with previous versions, that's my guess.

所以,当你用在gradle这个脚本中指定的applicationID 价值的APK,gradle这个替换表现的属性值。

So when you build your APK, gradle replaces manifest's package property value with applicationId value specified in gradle script.

如果你想测试它自己。只需设置的applicationID 用不同的价值,你的清单的和构建APK。然后进入到文件夹的 /编译/中间体/舱单的/ dev /调试的和开放的Andr​​oidManifest.xml。你会发现有的applicationID 值。

If you would like to test it yourself. Just set applicationId with different value that your manifest's package and build APK. Then go to folder /build/intermediates/manifests/dev/debug and open AndroidManifest.xml. You will find there applicationId value.

这篇关于如何在新的applicationID中的build.gradle工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆