Ant打包android程序步骤,及注意事项




http://blog.csdn.net/lonewolf521125/article/details/43022623

http://blog.csdn.net/lonewolf521125/article/details/43022623

http://blog.csdn.net/lonewolf521125/article/details/43022623

http://blog.csdn.net/lonewolf521125/article/details/43022623

http://blog.csdn.net/lonewolf521125/article/details/43022623



Ant打包android程序步骤,及注意事项

标签: antscriptandroid编译
1898人阅读 评论(0) 收藏 举报
本文章已收录于:
分类:
  1. Ant打包android程序步骤,及注意事项  
  2. =====================  
  3. 参考链接  
  4. Managing Projects from the Command Line  
  5. http://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject  
  6. Ant Build Android Project With Dependencies  
  7. http://stackoverflow.com/questions/12308849/ant-build-android-project-with-dependencies  
  8.   
  9. ------------------  
  10. **NOTE:在遇到各种android相关的问题中,通过baidu,google发现,其实最好的资源还是google的android相关网站http://developer.android.com/  
  11. 各种版本的答案,溯其源头,大部分都是来自此网站。  
  12. 故,有时间还是要多查看此网站,答案就在手头上! **  
  13.   
  14. >  **前提:**已创建了android项目,因某需求,需要Ant来管理  
  15.   
  16.   
  17. 项目说明  
  18. ----------------------------------  
  19.   
  20. *  实例项目的目录结构(应该是相对复杂的,如果了解了此项目的ant管理,那么一般项目基本无障碍)  
  21.   
  22.   
  23. > app  
  24. > > dependent  
  25. > > > actionbarsherlock-new  
  26. > > > android-times-sequare  
  27. > > > android-uitableview        
  28. > > > AppMsg-library         
  29. > > > customShapeImageView       
  30. > > > ResideMenu         
  31. > > > sliding_menu_library  
  32.   
  33.   
  34. * 依赖说明  
  35.     1.  app依赖于dependent目录中的actionbarsherlock-new,android-times-sequare,android-uitableview,AppMsg-library,customShapeImageView,ResideMenu,sliding_menu_library  
  36.     2.  sliding_menu_library依赖于actionbarsherlock-new  
  37.   
  38. 管理步骤  
  39. ---------------  
  40.   
  41.   
  42. 1. **变更工程,使用Ant来管理**  
  43.   
  44.     *  **正常项目工程(如本实例中的app)**  
  45.         进入根目录,然后执行以下代码:  
  46.          > android update project --name app --target android-20 --path .  
  47.   
  48.     具体参数说明查看: http://developer.android.com/tools/projects/projects-cmdline.html#UpdatingAProject  
  49.   
  50.     * **如果是第三方依赖库(如本实例中的actionbarsherlock-new等)**  
  51.         进入对应的第三方库文件的目录,执行以下代码  
  52.         > android update lib-project --target android-20 --path .  
  53.   
  54.   
  55. 执行之后的目录结构如下:  
  56.   
  57. > app  
  58. > > dependent  
  59. > > > actionbarsherlock-new  
  60. > > > > AndroidManifest.xml  
  61. > > > > build.xml  
  62. > > > > local.properties  
  63. > > > > project.properties  
  64.   
  65. > > > android-times-sequare  
  66. > > > > AndroidManifest.xml  
  67. > > > > build.xml  
  68. > > > > local.properties  
  69. > > > > project.properties  
  70.   
  71.           
  72. > > > android-uitableview  
  73. > > > > AndroidManifest.xml  
  74. > > > > build.xml  
  75. > > > > local.properties  
  76. > > > > project.properties  
  77. > > > >   
  78. > > > AppMsg-library  
  79. > > > > AndroidManifest.xml  
  80. > > > > build.xml  
  81. > > > > local.properties  
  82. > > > > project.properties  
  83.             >   
  84. > > > customShapeImageView  
  85. > > > > AndroidManifest.xml  
  86. > > > > build.xml  
  87. > > > > local.properties  
  88. > > > > project.properties  
  89.             >   
  90. > > > ResideMenu  
  91. > > > > AndroidManifest.xml  
  92. > > > > build.xml  
  93. > > > > local.properties  
  94. > > > > project.properties  
  95.             >   
  96. > > > sliding_menu_library  
  97. > > > > AndroidManifest.xml  
  98. > > > > build.xml  
  99. > > > > local.properties  
  100. > > > > project.properties  
  101.             >   
  102.       
  103. > AndroidManifest.xml  
  104. > build.xml  
  105. > local.properties  
  106. > project.properties  
  107.   
  108. **2. 增加所需文件**  
  109. * 在根目录增加以下两个文件:  
  110.     * custom_rules.xml  
  111.         内容如下:  
  112.             <?xml version="1.0" encoding="UTF-8"?>  
  113.             <project name="app">  
  114.                 <property file="ant.properties" />  
  115.                 <property file="local.properties" />  
  116.                 <property name="out.dir" value="out" />  
  117.             </project>  
  118.     * ant.properties  
  119.         内容如下:  
  120.             #签名文件  
  121.             key.store=app-release-key.keystore  
  122.             #密码  
  123.             key.store.password=pswd  
  124.             #别名  
  125.             key.alias=alias  
  126.             #别名对应密码  
  127.             key.alias.password=pswd  
  128.             #混淆文件  
  129.             proguard.config=proguard-project.txt  
  130.   
  131. **3.clean并编译项目**  
  132. 在根目录中执行  
  133. > ant clean release  
  134.   
  135. 一般会运行失败...>_<  
  136.   
  137. 注意事项:  
  138. -------  
  139. 1. 项目配置  
  140.     * 查看app目录中的project.properties文件,是否如下:【1】  
  141.     >    android.library.reference.1=dependent/actionbarsherlock-new  
  142.     >    android.library.reference.2=dependent/android-times-sequare  
  143.     >    android.library.reference.3=dependent/android-uitableview  
  144.     >    android.library.reference.4=dependent/AppMsg-library  
  145.     >    android.library.reference.5=dependent/customShapeImageView  
  146.     >    android.library.reference.6=dependent/ResideMenu  
  147.     >    android.library.reference.7=dependent/sliding_menu_library  
  148.     >    \# Project target.  
  149.     >    target=android-20  
  150.   
  151.     * 查看各第三方库(除sliding_menu_library外)目录中的project.properties,是否如下:【2】  
  152.     >    \# Project target.  
  153.     >    target=android-20  
  154.     >    **android.library=true**  
  155.     * 查看sliding_menu_library目录中的project.properties文件,是否如下:【3】  
  156.     >    **android.library.reference.1=../actionbarsherlock-new**  
  157.     >    \# Project target.  
  158.     >    target=android-20  
  159.     >    **android.library=true**  
  160. 2. 注意点:  
  161.     * 对比【1】、【2】、【3】可知,如果是第三方库的话,project.properties文件中一定有:`android.library=true`  
  162.     * 对第三方库的引用,路径是相对的,否则可能会出现含有如下文字的异常:  
  163.     >    resolve to a path with no project.properties file for project     
  164.       
  165.     原因查看此处: http://stackoverflow.com/questions/12308849/ant-build-android-project-with-dependencies  
  166.   
  167.   
  168.   
  169. 3.**排查异常时,仔细分析异常**  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值