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

相关文章

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

android打包解包boot.img,system.img

原帖地址:http://www.52pojie.cn/thread-488025-1-1.html 转载Mark一下,日后研究 最近工作需要对boot.img,system.img进行破解。顺便将心得分享一下。 我的工作环境是在linux下的。所以工具都是针对linux的。 boot.img破解相关工具: 1、split_boot    perl脚本 2、boot_i

MTK Android P/Q system/vendor/super快速打包

一、Android 新版本默认开启了动态分区,把system vendor  product等分区打包成一个super分区。这对于我们使用替换分区的方法来排查问题不是很方便,直接替换一个super也不知道到底是哪个部分导致的。所以我们需要自己制作super.img来缩小范围。下面讲讲如何快速生成system、vendor、super,以及vbmeta(校验image,不匹配可能会导致不开机) 二

MTK AndroidP/Q快速打包ramdisk

一、Android P/Q ramdisk与老版本的差异 Android老版本的ramdisk是out下的root/ramdisk打包而来,里面包含了init  /sbin  init.rc   default.prop等文件。是一个完整的ramdisk Android新版本ramdisk分为了out 下的ramdisk目录和root目录,init ,init.rc等文件大部分都放到了syst

Android P/Q MTK平台无依赖打包boot.img

背景:        有时排查版本问题,需要用到替换img的方式来查找问题出现在哪个img,若出现在bootimg,那到底是kernel、DTB 还是ramdisk。此时就需要单独替换其中一个的方式来打包,之前直接make bootimage-nodeps就可以了,但现在发现执行这个命令无效了。下面就分析下新版本如何找到正确的打包命令。 一、找到编译boot的命令 之前Android编译lo

Qt5项目打包

笔者本来想尝试将项目在Windows环境和Linux环境下都打包发布,但是Linux环境下各种办法都尝试了,还是有点问题,先总结记录下吧。 参考文章:https://blog.csdn.net/windsnow1/article/details/78004265 http://www.cnblogs.com/lvdongjie/p/7250547.html http://doc.qt.io/ar

Java中WebService接口的生成、打包成.exe、设置成Windows服务、及其调用、Apache CXF调用

一、Java中WebService接口的生成: 1、在eclipse工具中新建一个普通的JAVA项目,新建一个java类:JwsServiceHello.java package com.accord.ws;import javax.jws.WebMethod;import javax.jws.WebService;import javax.xml.ws.Endpoint;/*** Ti

Axure元件库Ant Design中后台原型模板:提升设计与开发效率的利器

企业对于中后台产品的设计与开发需求日益增长。为了提升用户体验和开发效率,设计者和开发者们不断寻求更加高效、统一的解决方案。Ant Design,作为阿里巴巴开源的一套企业级UI设计语言和React组件库,凭借其丰富的组件和统一的设计风格,已成为众多项目的首选。而在Axure中使用Ant Design元件库,更是为中后台产品的原型设计带来了极大的便利。 Ant Design简介 Ant D

将 python 文件打包为exe文件

可以使用 PyInstaller 来将 Python 文件打包为可执行的 .exe 文件。以下是基本的步骤: 安装 PyInstaller: pip install pyinstaller 打包 Python 文件: 在终端中运行以下命令: pyinstaller --onefile your_script.py –onefile 选项将所有文件打包到一个 .exe 文件中。 找