Android应用的打包

来源:互联网 发布:淘宝企业店铺开店要求 编辑:程序博客网 时间:2024/05/16 07:22

为什么Android应用需要打包?

Android系统要求具有其开发者签名的私人密钥的应用程序才能够被安装。因此,打包之后才能发布该应用。

打包的步骤?

1. 选中项目–>”Android Tools”–>”Export Signed Application Package…”

这里写图片描述

2. 点击”next”

这里写图片描述
其中,Location为证书库将要存放的位置,Password是证书库的密码。

3. 选择”Create new keystore”新创建一个证书库,单击”Browse…”按钮选择证书库将要保存的位置并填入信息。

这里写图片描述
什么是keystore?
Keystore是一种数字证书,可以用来识别发布者的身份。数字证书含有两部分数据:一部分是发布者的信息,另一部分是所对应的公钥。Android Market要求每一个app都提供一个证书,这样在应用发布之后,拥有私钥的发布者就可以随时更新版本。

4. 如果已经拥有一个证书,那么可以选择”Use existing keystore”,然后直接选择keystore的位置。

这里写图片描述

什么是Gradle?Gradle和打包有什么关系?

Gradle is a build automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the more traditional XML form of declaring the project configuration. Gradle uses a directed acyclic graph (“DAG”) to determine the order in which tasks can be run[1].
Build和complie有什么区别和联系?
Compiling is the act of turning source code into object code.
Linking is the act of combining object code with libraries into a raw executable.
Building is the sequence composed of compiling and linking, with possibly other tasks such as installer creation[2].
Gradle可以实现app的批量打包和多渠道打包。
什么是多渠道打包?
Android市场有众多的渠道(如豌豆荚、应用宝等)。为了统计每个渠道的下载数据,我们需要针对不同渠道打包。可以在AndroidManifest.xml里或用java代码设置渠道。如果手工做这件事,那是相当麻烦的,每个渠道都要改一次代码,单独导出一个apk,但Gradle可以帮我们完成这些工作[3]。

0 0
原创粉丝点击