|
<?xml version="1.0" encoding="UTF-8"?>
<project name="apkTargets" default="apkpackaging" basedir=".">
<!-- 指定配置文件 -->
<property file="build.properties" />
<record name="${log_file}" loglevel="info" append="no" action="start" />
<!-- 识别编译环境 -->
<condition property="exe" value=".exe" else=""><os family="windows" /></condition>
<condition property="bat" value=".bat" else=""><os family="windows" /></condition>
<!-- Android SDK Tools -->
<property name="zipalign" value="${android_tools}/zipalign${exe}" />
<property name="jarsigner" value="${jdk_home}/bin/jarsigner${exe}" />
<!-- some file directory exclude "bin" file, because "bin" file will be changed each loop -->
<property name="bin-dir" value="bin" />
<!-- 主工程各个目录 -->
<property name="host-src" value="${project_home}/src" />
<property name="host-libs" value="${project_home}/libs" />
<property name="intermediate-dex" value="${project_home}/${bin-dir}/${app_name}/classes.dex" />
<!-- The final package file to generate -->
<property name="resources-package" value="${project_home}/${bin-dir}/${app_name}/${app_name}.ap_" />
<property name="out-unsigned-package" value="${project_home}/${bin-dir}/${app_name}/${app_name}-unsigned.apk" />
<property name="out-signed-package" value="${project_home}/${bin-dir}/${app_name}/${app_name}-signed.apk" />
<property name="zipalign-package" value="${output_path}/${app_name}_for_android_${android_version}.apk" />
<target name="apkpackaging" depends="zipalign,jarsigner,apkbuilder"/>
<!-- 1.使用zipalign做优化,对apk文件进行对齐 -->
<target name="zipalign" depends="jarsigner">
<exec executable="${zipalign}" failonerror="true">
<!-- 打印详细日志 -->
<!-- <arg value="-v" /> -->
<arg value="-f" />
<arg value="4" />
<arg value="${out-signed-package}" />
<!-- arg value="${out-unsigned-package}" /> -->
<arg value="${zipalign-package}" />
</exec>
<echo>打包完成:${zipalign-package}</echo>
</target>
<!-- 2.APK签名 -->
<target name="jarsigner" depends="apkbuilder">
<exec executable="${jarsigner}" failonerror="true">
<!-- 打印详细日志 -->
<!-- <arg value="-verbose" /> -->
<!-- 签名信息 -->
<arg value="-keystore" />
<arg value="${key_store}" />
<arg value="-storepass" />
<arg value="${key_store_password}" />
<arg value="-keypass" />
<arg value="${key_alias_password}" />
<!-- 输出安装包 -->
<arg value="-signedjar" />
<arg value="${out-signed-package}" />
<arg value="${out-unsigned-package}" />
<arg value="${key_alias}" />
<!-- -->
<arg value="-digestalg" />
<arg value="SHA1" />
<arg value="-sigalg" />
<arg value="MD5withRSA" />
</exec>
</target>
<!-- 3.APK打包 -->
<target name="apkbuilder" >
<java classpath="${android_apk_tools}/lib/sdklib.jar" classname="com.android.sdklib.build.ApkBuilderMain" fork="true" failonerror="true">
<sysproperty key="file.encoding" value="UTF-8" />
<!-- 创建未签名的包 -->
<arg value="${out-unsigned-package}" />
<arg value="-u" />
<arg value="-z" />
<arg value="${resources-package}" />
<!-- dex中间文件 -->
<arg value="-f" />
<arg value="${intermediate-dex}" />
<!-- Adds the java resources found in that folder -->
<arg value="-rf" />
<arg value="${host-src}" />
<!-- add native libraries -->
<arg value="-nf" />
<arg value="${host-libs}" />
<arg value="-nf" />
<arg value="${library_1}/libs" />
<arg value="-nf" />
<arg value="${library_2}/libs" />
<!-- Adds the java resources found in the jar file(s) -->
<arg value="-rj" />
<arg value="${host-libs}" />
<arg value="-rj" />
<arg value="${library_1}/libs" />
<arg value="-rj" />
<arg value="${library_2}/libs" />
</java>
</target>
</project>
|