ANT多渠道打包

2024-06-07 17:58
文章标签 ant 打包 多渠道

本文主要是介绍ANT多渠道打包,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

ANT多渠道打包

安装ANT

ant下载地址
http://ant.apache.org/

配置环境变量
新建ANT_HOME环境变量,值为ant所在的目录,然后将ANT_HOME/bin添加到path中

由于ant不支持循环需要下载ant-contrib
http://yunpan.cn/c3sn5NdCz7KTF  访问密码 45a2
将ant-contrib-1.0b3.jar文件放到ant目录下的lib目录

为Android项目生成Ant配置build.xml

首先创建一个安卓工程testAnt
打开命令行工具 cd到工程目录
android update project --name <project_name> --target <target_ID>--path <path_to_your_project>

例如
android update project --name testAnt --target 20 --path E:\workplace\testAnt

命令执行完毕会在工程的目录下创建 build.xml 和 local.properties两个文件

编写ant.properties

在工程目录创建一个ant.properties文件

key.alias=yourkeystore
key.alias.password=yourpassword
key.store=../keystore/XXXXX.keystore
market_channels=9990091,9990092,9990093,9990094,9990095app_name=testAnt
app_version=1.0

local.properties文件中添加出包路径
target.dir=E:\\workspace\\testAnt\\antApks

编写build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="testAnt" 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 intoVersion 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.dirThe name of the source directory. Default is 'src'.out.dirThe name of the output directory. Default is 'bin'.For other overridable properties, look at the beginning of the rulesfiles in the SDK, at tools/ant/build.xmlProperties related to the SDK location or the project target shouldbe updated using the 'android' tool with the 'update' action.This file is an integral part of the build system for yourapplication and should be checked into Version Control Systems.--><property file="ant.properties" /><echo>${market_channels}</echo>  <echo>${app_version}</echo>  <!-- 支持循环执行 -->  <taskdef resource="net/sf/antcontrib/antcontrib.properties" >  <classpath>  <pathelement location="${ant.dir}/lib/ant-contrib-1.0b3.jar" />  </classpath>  </taskdef>  <echo>Run ant-contrib-1.0b3.jar ok</echo>  <target name="deploy">   <foreach target="edit_and_build" list="${market_channels}" param="channel" delimiter=",">   </foreach>   </target>  <target name="edit_and_build">   <echo>Run '${channel}' apk</echo>  <replaceregexpencoding="utf-8"file="AndroidManifest.xml"flags="s"match="<meta\-data(\s+)android:name="DC_CHANNEL"(\s+)android:value="[a-zA-Z0-9]+""replace="<meta\-data android:name="DC_CHANNEL" android:value="${channel}""/><property name="out.final.file"  location="${target.dir}/${app_version}/${app_name}.${channel}.apk" /> <antcall target="clean" />  <antcall target="release" />  </target>   <!-- if sdk.dir was not set from one of the property file, thenget it from the ANDROID_HOME env var.This must be done before we load project.properties sincethe 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 librarydependencies. 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 yourapplication and should be checked into Version Control Systems. --><loadproperties srcFile="project.properties" /><!-- quick check on sdk.dir --><failmessage="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>


命令行到工程目录 

ant deploy



这篇关于ANT多渠道打包的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1039888

相关文章

PyInstaller打包selenium-wire过程中常见问题和解决指南

《PyInstaller打包selenium-wire过程中常见问题和解决指南》常用的打包工具PyInstaller能将Python项目打包成单个可执行文件,但也会因为兼容性问题和路径管理而出现各种运... 目录前言1. 背景2. 可能遇到的问题概述3. PyInstaller 打包步骤及参数配置4. 依赖

Flutter打包APK的几种方式小结

《Flutter打包APK的几种方式小结》Flutter打包不同于RN,Flutter可以在AndroidStudio里编写Flutter代码并最终打包为APK,本篇主要阐述涉及到的几种打包方式,通... 目录前言1. android原生打包APK方式2. Flutter通过原生工程打包方式3. Futte

linux打包解压命令方式

《linux打包解压命令方式》文章介绍了Linux系统中常用的打包和解压命令,包括tar和zip,使用tar命令可以创建和解压tar格式的归档文件,使用zip命令可以创建和解压zip格式的压缩文件,每... 目录Lijavascriptnux 打包和解压命令打包命令解压命令总结linux 打包和解压命令打

将java程序打包成可执行文件的实现方式

《将java程序打包成可执行文件的实现方式》本文介绍了将Java程序打包成可执行文件的三种方法:手动打包(将编译后的代码及JRE运行环境一起打包),使用第三方打包工具(如Launch4j)和JDK自带... 目录1.问题提出2.如何将Java程序打包成可执行文件2.1将编译后的代码及jre运行环境一起打包2

配置springboot项目动静分离打包分离lib方式

《配置springboot项目动静分离打包分离lib方式》本文介绍了如何将SpringBoot工程中的静态资源和配置文件分离出来,以减少jar包大小,方便修改配置文件,通过在jar包同级目录创建co... 目录前言1、分离配置文件原理2、pom文件配置3、使用package命令打包4、总结前言默认情况下,

Python项目打包部署到服务器的实现

《Python项目打包部署到服务器的实现》本文主要介绍了PyCharm和Ubuntu服务器部署Python项目,包括打包、上传、安装和设置自启动服务的步骤,具有一定的参考价值,感兴趣的可以了解一下... 目录一、准备工作二、项目打包三、部署到服务器四、设置服务自启动一、准备工作开发环境:本文以PyChar

Python pyinstaller实现图形化打包工具

《Pythonpyinstaller实现图形化打包工具》:本文主要介绍一个使用PythonPYQT5制作的关于pyinstaller打包工具,代替传统的cmd黑窗口模式打包页面,实现更快捷方便的... 目录1.简介2.运行效果3.相关源码1.简介一个使用python PYQT5制作的关于pyinstall

javafx 如何将项目打包为 Windows 的可执行文件exe

《javafx如何将项目打包为Windows的可执行文件exe》文章介绍了三种将JavaFX项目打包为.exe文件的方法:方法1使用jpackage(适用于JDK14及以上版本),方法2使用La... 目录方法 1:使用 jpackage(适用于 JDK 14 及更高版本)方法 2:使用 Launch4j(

springboot3打包成war包,用tomcat8启动

1、在pom中,将打包类型改为war <packaging>war</packaging> 2、pom中排除SpringBoot内置的Tomcat容器并添加Tomcat依赖,用于编译和测试,         *依赖时一定设置 scope 为 provided (相当于 tomcat 依赖只在本地运行和测试的时候有效,         打包的时候会排除这个依赖)<scope>provided

android6/7 system打包脚本

1.android5打包system就是网站上常见的制作ROM必备的解包打包system脚本 指令如下:mkuserimg.sh -s out/target/product/$TARGET_PRODUCT/system out/target/product/$TARGET_PRODUCT/obj/PACKAGING/systemimage_intermediates/system.img