使用ant自动化构建android项目

   学习步骤
   a. 学习简单的android项目打包
   参考网址:
   http://my.eoe.cn/luoxiangyu001/archive/3430.html
  
   根据readme,修改local.property
   sdk.dir = /Users/chenxu/developer/android-sdk-macosx

   b. 下载安装ant扩展包 antcontrib
   查找ant路径 whereis ant
   /usr/bin/ant
   安装路径为 /usr/share/ant

   复制jar到安装路径
   sudo cp /ant-contrib-0.3.jar /usr/share/ant/ant-contrib-0.3.jar

   c. 尝试编译ant报错
   d. 复制xxx.keystore数字签名文件到当前工程根目录
  附:mac环境下修改名称的命令
        mv olderfilename newfilename

   e. 修改build.xml配置ant-contrib.jar路径
   <taskdef resource="net/sf/antcontrib/antcontrib.properties" >
        <classpath>
            <pathelement location="/usr/share/ant/lib/ant-contrib-1.0b3.jar" />
        </classpath>
    </taskdef>

    f. 继续编译 ant
    报错信息:
    /Users/chenxu/work/java/MapsDemo/build.xml:132: The following error occurred while executing this line:
    解决:
    <copy tofile="${gos.path}/MapsDemo_${channel}.apk" >
        <fileset
                dir="${out.absolute.dir}/"
                includes="MapsDemo-release.apk" />
        </copy>
    MapsDemo是工程名称,必须全局保持一致
    ant.project.name=MapsDemo

    <project
    name="MapsDemo"
    default="deploy" >

    g. 编译成功, MapsDemo-release.apk等各个渠道包成功输出到目标路径

    h. 使用命令可以安装apk
    ant install apk

    i. 如何生成数字签名
    $ keytool -genkey -v -keystore nbtlxx.keystore -alias nbtlxx -keyalg RSA --validity 10000
    一路根据向导输入相关内容,注意保存;

参考github代码
[url]https://github.com/chenxu111/anttest [/url]

猜你喜欢

转载自nbtlxx.iteye.com/blog/1999771