使用Jenkins Build Android心得
来源:互联网 发布:java解决int数值上限 编辑:程序博客网 时间:2024/06/05 21:16
Android Build Process
http://developer.android.com/tools/building/index.html
The build processinvolves many tools and processes that generate intermediate files on the wayto producing an .apk
.If you are developing in Eclipse, the complete build process is automaticallydone periodically as you develop and save your code changes. If you are usingother IDEs, this build process is done every time you run the generated Antbuild script for your project. It is useful, however, to understand what ishappening under the hood since much of the tools and processes are masked fromyou. The following diagram depicts the different tools and processes that areinvolved in a build:
The general process for a typicalbuild is outlined below:
· The Android Asset Packaging Tool(aapt) takes your application resource files, such as the AndroidManifest.xml
file and the XML files for your Activities, and compiles them.An R.java
is also produced so you can reference your resources from yourJava code.
· The aidl tool converts any .aidl
interfaces that you have into Java interfaces.
· All of your Java code, includingthe R.java
and .aidl
files, are compiled by the Java compiler and .class files areoutput.
· The dex tool converts the .classfiles to Dalvik byte code. Any 3rd party libraries and .class files that youhave included in your project are also converted into .dex
files so that they can be packaged into the final .apk
file.
· All non-compiled resources (suchas images), compiled resources, and the .dex files are sent to the apkbuildertool to be packaged into an .apk
file.
· Once the .apk
is built, it must be signed with either a debug or release keybefore it can be installed to a device.
· Finally, if the application isbeing signed in release mode, you must align the .apk
with the zipalign tool. Aligning the final .apk
decreases memory usage when the application is running on adevice.
Deploy Jenkins on Windows7
Install
Download Ant.
You can obtainit from the Apache Ant home page.
Download Android SDK
http://developer.android.com/sdk/index.html
Download Jenkins
http://jenkins-ci.org/
Download JDK
http://www.oracle.com/us/downloads/index.html
建议安装顺序JDK, Android SDK, Ant, Jenkins
配置
JDK&ANT
可以设置JDK和ANT的环境变量,也可以稍后在Jenkins系统管理页面制定。基本的安装和设定网上有很多教程,不再重复,可以访问127.0.0.1:8080之后才有点特殊。
Jenkins启动
Start: Jenkins.exe start
Stop: Jenkins.exe stop
Restart: Jenlins.exe restart
Jenkins配置
因为需求是可以每天定时Build不同版本APK,并且可以将,APK,Build结果,静态代码分析等结果,发邮件通知相关人员。
进入Jenkins-> 系统管理 -> 系统设置
Jenkins Location
JenkinsURL 这个URL用于在邮件中生成有关的链接。最好指向一个域名。
SystemAdmin e-mail address 管理员的Email,这里一定要设置对,不然后面Mail Server设置时候测试可能失败。
Subversion
建议选最新的
邮件通知
指定好SMTP服务器地址,端口号,用户名,密码就可以。
Jenkins插件
确认安装Subversion Plugin, Email-ext plugin。建议把FindBugs给装上。
项目配置
给Project添加ANT支持。找到SDK中的android.bat在命令行下执行
android update project –p android-app –txxx
成功的话,尝试用 ant debug应该成功build
添加了ANT之后,在项目目录下会多了一个build.xml。一般Android在Eclipse中创建的时候是不带这个ANT支持的,如果是这种情况,等创建Jenkins Job好,执行一次后,也就是SVN checkout 后,找到Project,再执行android update。
添加签名信息:
在build.xml相同目录下,新建一个ant.properties,里面填入如下内容,build时候会检测这个文件,读取里面keystore的设置。
Jenkins Job
在Jenkins 首页左边的选项中,选择“新建”,新建一个任务,选择“构建一个自由风格的软件项目”。
源码管理:选择Subversion,输入ProjectSVN address. 以及验证信息。
触发器:可以设置定时执行任务。
构建:先添加一个InvokeAnt。Ant version 选择Default。Targets就是build.xml中的target。如果是build.xml是默认的,可以选择release, debug等。由于为了发多渠道的APK。这里自定义了Build.xml,所以Target也是自定义的releaseAll。具体Build.xml 后面再细说。
如果还要执行自定的脚本,可以加在这里。例如,我这里加了一个自定义的jar。添加Execute Windows batch command,命令是“java –jarD:\misc\copy.jar”希望Build之后执行copy.jar,用来复制生成的APK到制定目录,并生成信息(APK的描述,下载链接等),写入一个文件,稍后把这些内容作为邮件的一部分。
构建后操作:添加一个EditableEmail Notification。用于构建后发邮件,特殊的是,邮件的内容,两部分,第一行是读取上面说的copy.jar生成的内容。第二行是邮件模板,这里用的是dd.groovy.template。
- 使用Jenkins Build Android心得
- Jenkins 使用心得
- Android 自动build + jenkins配置
- VC Post-build使用心得
- jenkins:使用 Jenkins 实现持续集成 (Android)
- android jenkins ant build.xml replaceregexp regexp substitution
- jenkins 安装,配置 和 运行 & Build Pipeline 插件的使用
- 用Jenkins做build
- Jenkins build Qt project
- Jenkins下ant build
- Jenkins中的build periodically
- Jenkins-Build Monitor View
- Jenkins插件groovy-postbuild使用(一)-获取jenkins环境变量值和获取build结果
- Unity3d使用Jenkins打包Android
- 学习jenkins+git+gradle实现Android持续集成心得总结
- Android模拟器使用心得
- Android Vcard使用心得
- Android Vcard使用心得
- 给应用程序的图标选择颜色
- ALLJOYN源码阅读笔记
- 六种查找算法效率比较
- 阿尔乪
- 归并排序求逆序数
- 使用Jenkins Build Android心得
- 如何写出无法维护的代码
- 笔记
- UVA 11995 I Can Guess the Data Structure!
- iOS用流的形式上传文件
- 测试android横竖屏切换、按home键、按返回键所触发的生命周期
- 阅读器订阅
- iOS基础一 UISwitch
- 好程序员和差程序员