Android 多渠道自动打包
来源:互联网 发布:武汉网络诈骗团伙名单 编辑:程序博客网 时间:2024/05/02 14:10
首先确保你已经配置好了Android 开发环境,并创建了ANDROID_SDK_HOME 环境变量。
ANT配置
下载Ant并解压,这里我们选择了ant-1.9.0 解压目录是D:\JAVA\apache-ant-1.9.0 配置环境变量ANT_HOME=D:\JAVA\apache-ant-1.9.在PATH中添加 %ANT_HOME%\bin;
ant-contrib-1.0b3.jar 配置
下载ant-contrib-1.0b3.jar 并将其放到D:\JAVA\apache-ant-1.9.0\lib中。
build.xml创建
Available Android targets:----------id: 1 or "android-10"Name: Android 2.3.3Type: PlatformAPI level: 10Revision: 2Skins:ABIs : no ABIs.----------id: 2 or "android-19"Name: Android 4.4.2Type: PlatformAPI level: 19Revision: 2Skins: HVGA, QVGA, WQVGA400, WQVGA432, WSVGA, WVGA800 (default), WVGA854, WXGA720, WXGA800, WXGA800-7inABIs : armeabi-v7a
<pre name="code" class="html"><?xml version="1.0" encoding="UTF-8"?><project name="MainActivity" default="help"> <!-- The local.properties file is created and updated by the 'android' tool. It contains the path to the SDK. It should *NOT* be checked into Version Control Systems. --> <property file="local.properties" /> <!-- The ant.properties file can be created by you. It is only edited by the 'android' tool to add properties to it. This is the place to change some Ant specific build properties. Here are some properties you may want to change/update: source.dir The name of the source directory. Default is 'src'. out.dir The name of the output directory. Default is 'bin'. For other overridable properties, look at the beginning of the rules files in the SDK, at tools/ant/build.xml Properties related to the SDK location or the project target should be updated using the 'android' tool with the 'update' action. This file is an integral part of the build system for your application and should be checked into Version Control Systems. --> <property file="ant.properties" /> <!-- if sdk.dir was not set from one of the property file, then get it from the ANDROID_HOME env var. This must be done before we load project.properties since the proguard config can use sdk.dir --> <property environment="env" /> <condition property="sdk.dir" value="${env.ANDROID_HOME}"> <isset property="env.ANDROID_HOME" /> </condition> <!-- The project.properties file is created and updated by the 'android' tool, as well as ADT. This contains project specific properties such as project target, and library dependencies. Lower level build properties are stored in ant.properties (or in .classpath for Eclipse projects). This file is an integral part of the build system for your application and should be checked into Version Control Systems. --> <loadproperties srcFile="project.properties" /> <!-- quick check on sdk.dir --> <fail message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." unless="sdk.dir" /> <!-- Import per project custom build rules if present at the root of the project. This is the place to put custom intermediary targets such as: -pre-build -pre-compile -post-compile (This is typically used for code obfuscation. Compiled code location: ${out.classes.absolute.dir} If this is not done in place, override ${out.dex.input.absolute.dir}) -post-package -post-build -pre-clean --> <import file="custom_rules.xml" optional="true" /> <!-- Import the actual build file. To customize existing targets, there are two options: - Customize only one target: - copy/paste the target into this file, *before* the <import> task. - customize it to your needs. - Customize the whole content of build.xml - copy/paste the content of the rules files (minus the top node) into this file, replacing the <import> task. - customize to your needs. *********************** ****** IMPORTANT ****** *********************** In all cases you must update the value of version-tag below to read 'custom' instead of an integer, in order to avoid having your file be overridden by tools such as "android update project" --> <!-- version-tag: 1 --> <import file="${sdk.dir}/tools/ant/build.xml" /></project>
<?xml version="1.0" encoding="UTF-8"?><project name="HelloWorld" default="release"> <!-- The local.properties file is created and updated by the 'android' tool. It contains the path to the SDK. It should *NOT* be checked into Version Control Systems. --> <property file="local.properties" /> <!-- The ant.properties file can be created by you. It is only edited by the 'android' tool to add properties to it. This is the place to change some Ant specific build properties. Here are some properties you may want to change/update: source.dir The name of the source directory. Default is 'src'. out.dir The name of the output directory. Default is 'bin'. For other overridable properties, look at the beginning of the rules files in the SDK, at tools/ant/build.xml Properties related to the SDK location or the project target should be updated using the 'android' tool with the 'update' action. This file is an integral part of the build system for your application and should be checked into Version Control Systems. --> <property file="ant.properties" /> <!-- if sdk.dir was not set from one of the property file, then get it from the ANDROID_HOME env var. This must be done before we load project.properties since the proguard config can use sdk.dir --> <property environment="env" /> <condition property="sdk.dir" value="${env.ANDROID_SDK_HOME}"> <isset property="env.ANDROID_SDK_HOME" /> </condition> <!-- The project.properties file is created and updated by the 'android' tool, as well as ADT. This contains project specific properties such as project target, and library dependencies. Lower level build properties are stored in ant.properties (or in .classpath for Eclipse projects). This file is an integral part of the build system for your application and should be checked into Version Control Systems. --> <loadproperties srcFile="project.properties" /> <!-- quick check on sdk.dir --> <fail message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." unless="sdk.dir" /> <!-- Import per project custom build rules if present at the root of the project. This is the place to put custom intermediary targets such as: -pre-build -pre-compile -post-compile (This is typically used for code obfuscation. Compiled code location: ${out.classes.absolute.dir} If this is not done in place, override ${out.dex.input.absolute.dir}) -post-package -post-build -pre-clean --> <import file="custom_rules.xml" optional="true" /> <!-- Import the actual build file. To customize existing targets, there are two options: - Customize only one target: - copy/paste the target into this file, *before* the <import> task. - customize it to your needs. - Customize the whole content of build.xml - copy/paste the content of the rules files (minus the top node) into this file, replacing the <import> task. - customize to your needs. *********************** ****** IMPORTANT ****** *********************** In all cases you must update the value of version-tag below to read 'custom' instead of an integer, in order to avoid having your file be overridden by tools such as "android update project" --> <!-- version-tag: 1 --> <import file="${sdk.dir}\tools\ant\build.xml" /> <property name="out.unaligned.dir" value="F:\HelloWorld_${app_version}/" /> <mkdir dir="${out.unaligned.dir}" /> <target name="modify_update_file"> <echo>*********************** make channel ${channel}</echo> <replaceregexp file="AndroidManifest.xml" match='channel' replace='${channel}' byline="false" encoding="utf-8" /> <property name="out.unaligned.file" location="${out.unaligned.dir}/HelloWorld_${app_version}_${channel}_android.apk"/> </target> <target name="make_one_channels" depends="savemanifest,modify_update_file,release,replacemanifest,deletebin" description="description"> </target> <target name="replacemanifest"> <echo>*********************** replacemanifest</echo> <delete file="${basedir}\AndroidManifest.xml"/> <copy file="..\temp\build\META-INF\AndroidManifest.xml" todir="${basedir}" encoding="utf-8"/> </target> <target name="savemanifest"> <echo>*********************** savemanifest</echo> <copy file="${basedir}\AndroidManifest.xml" todir="..\temp\build\META-INF" encoding="utf-8" /> </target> <target name="deletebin"> <delete dir="${basedir}\bin" /> </target> <taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" classpath="F:\adt-bundle-windows-x86-20131030\sdk\tools\lib\ant-contrib-1.0b3.jar" /> <target name="make_channels"> <foreach target="make_one_channels" list="${market_channels}" delimiter="," param="channel"> </foreach> </target></project><img src="http://img.my.csdn.net/uploads/201406/02/1401642364_9125.png" alt="" />修改点:1.0
<project name="HelloWorld" default="release">
2.0
<condition property="sdk.dir" value="${env.ANDROID_SDK_HOME}">
<isset property="env.ANDROID_SDK_HOME" />
</condition>
3.0
<property name="out.unaligned.dir" value="F:\HelloWorld_${app_version}/" /> 输出文件目录
4.0
<property name="out.unaligned.file" location="${out.unaligned.dir}/HelloWorld_${app_version}_${channel}_android.apk"/> 输出文件名称
5.0
6.0 注意<taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" classpath="F:\adt-bundle-windows-x86-20131030\sdk\tools\lib\ant-contrib-1.0b3.jar" /> 指定ant-contrib-1.0b3.jar文件目录。
<foreach target="make_one_channels" list="${market_channels}" delimiter="," param="channel">中的channel
和 AndroidManefest.xml 中的 <meta-data android:name="qudao" android:value="channel" /> channel 该值必须一样。根据该属性配置的
ant.properties 文件
key.alias=release_keykey.store.password=123456key.alias.password=123456market_channels=xx,yy,zzapp_version=1_0_build_0分别为:证书文件 别名 证书密码 别名密码 渠道名字 版本号这里的证书路径 一定已/ 分割 而不是\ (我在这里就遇到了问题
编译
继续执行命令:
ant make_channels
如果成功 会出现
BUILD SUCCESSFUL
Total time: 3 seconds 同时出现编译完的文件
自己编译时 出现的错误:
F:\adt-bundle-windows-x86-20131030\sdk\tools\ant\build.xml:1139: The following e
rror occurred while executing this line:
F:\adt-bundle-windows-x86-20131030\sdk\tools\ant\build.xml:1151: Value for 'keys
tore' is not valid. It must resolve to a single path
证书文件指定的路径不对导致。通过ant release命令也会得到同样的错误。
- android 多渠道自动打包
- Android 多渠道自动打包
- ant工具-多渠道自动打包android项目
- Android Studio使用Gradle多渠道自动打包
- Android-用apktool实现多渠道自动打包
- android-多渠道自动打包之一秒五包
- apk多渠道自动打包
- Android多渠道打包(一):基础多渠道打包
- Android多渠道打包(四):360多渠道打包
- Android多渠道打包(五):360多渠道打包+
- 脚本ANT自动打包Android应用(方便多渠道发布)
- Android——使用gradle进行多渠道自动打包
- android apk多渠道打包
- Android多渠道打包APK
- android 多渠道打包
- android应用多渠道打包
- Android Ant 多渠道打包
- Android多渠道Ant打包
- 小白自学Android路之 xml文件
- 递归查找无效的符号链接
- (Struts2学习篇) Struts2数据校验之一
- linux
- Exception in thread "main" java.lang.LinkageError: JAXB 2.1 API is being loaded from the bootstrap c
- Android 多渠道自动打包
- WCF 自托管
- strings命令的实现
- cf437D The Child and Zoo
- 关于UNIQUE联合索引的一个小技巧
- Unity3D添加天空盒
- 数据拷贝的实现
- Unity3D 快捷键
- 黑马程序员_IO流