使用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。

        

 

 

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 华硕打不开机怎么办 飞利浦电视待机打不开怎么办 微信支付扫码牌怎么办 微信付款没扣钱怎么办 移动充值卡有效期到了怎么办 联华提货券过期怎么办 狗吃了西红柿怎么办 加盟总店关了怎么办 欧亚超市购物卡怎么办 欠招行信用卡一万多逾期怎么办 白条取现失败怎么办 啤酒喝醉了难受怎么办 喝啤酒喝醉头疼怎么办 运动鞋鞋子大了怎么办 运动鞋买大一号怎么办 跑鞋买大了怎么办 鞋子大一个手指怎么办 一体式手机死机怎么办 ivvi手机声音小怎么办 单位欠缴社保怎么办 哆点错误代码1怎么办 忘记密码怎么办简单一点 智校园忘记密码怎么办 wps图片显示空白怎么办 dr.com闪退怎么办 联想笔记本连不上无线网络怎么办 长时间不用电池休眠怎么办? 校园电信卡欠费怎么办 校园联通卡欠费怎么办 校园网等不上怎么办 app显示尚未授权怎么办 手机屏有气泡怎么办 平板老是闪退怎么办 挖机环保不合格怎么办 摩托车高压火弱怎么办 助力转向机漏油怎么办 淘宝运费险不够怎么办 iphonex锁屏延迟怎么办 淘宝不能评价了怎么办 微商卖香烟不发货怎么办? 三诺血糖仪不准怎么办