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

相关文章

打包体积分析和优化

webpack分析工具:webpack-bundle-analyzer 1. 通过<script src="./vue.js"></script>方式引入vue、vuex、vue-router等包(CDN) // webpack.config.jsif(process.env.NODE_ENV==='production') {module.exports = {devtool: 'none

AndroidStudio打包处理

AndroidStudio非常强大,公司最近有一个需求是要实现对一个APP进行多个版本的打包,而且可以同时安装在手机上。这个需求详细一点的描述是:公司有一个APP,有多个开发商要使用我们的APP,为了大家都想有一个自己的APP,而且图标不一样,app名字不一样,背景不一样等。我查询了一下资料发现,在AndroidStudio的gradle是可以配置的。在此特意写一篇文章记录分享。 配置签名 首

Tkinter和selenium结合实现登录UC后台,最后打包成exe

主要实现的功能:小号模式自动登录UC阿里汇川广告后台,屏蔽账号密码输入 主要用的技术:用Tkinter展示所有的广告账号界面,使用selenium控制谷歌浏览器,打开阿里汇川登录页,登录汇川后台。 第一次写,遇到的坑比较多,三天,搞定。给自己一个棒棒~☺️ import Tkinter as tk import osimport sysimport requestsfrom sel

【Vite】控制打包结构

配置 vite.config.json 文件: import { defineConfig } from "vite";export default defineConfig({// ...build: {rollupOptions: {output: {entryFileNames: "js/[name]-[hash].js",chunkFileNames: "js/[name]-[hash]

ANT介绍及ANT系统环境变量的配置

Apache Ant,是一个基于JAVA的自动化脚本引擎,脚本格式为XML。除了做JAVA编译相关任务外,ANT还可以通过插件实现很多应用的调用。默认情况下,脚本文件名为build.xml 简单说来可以这么理解,如果你用记事本写JAVA程序,然后在cmd里输入javac命令编译它,但是有一天你发现每次手动输入太麻烦而且都是重复劳动,于是你下决心改变这种状况,然后学会了把javac命令写到一个b

在eclipse中进行nutch1.7二次开发通过ant编译build.xml出现Class not found javac1.8

把nutch1.7通过svn导入到本地后打算进行二次开发却在开始用ant进行build.xml构建的时候出现Class not found javac1.8 暂且不管哪个sonar没有找到的问题,我们先把那个Class not found :javac1.8的问题: 多半是因为Ant版本太低,低于1.9,无法和java1.8兼容,因为我的java运行环境是1.8的,Ant版本也是1.8,所

用通俗到业余水平的语言教你编译和打包

本文从零开始讲述编译的基本过程,希望菜鸟们能喜欢。毕竟Linux下的软件,源代码是多于二进制包的,学会了编译,再安装软件就不求别人了。所以,编译也是Linux菜鸟必修的一课。 1,安装编译工具。 $ sudo apt-get install dpkg-dev file gcc g++ libc6-dev make patch perl autoconf automake dh-ma

uniapp wgt多环境打包与调试插件——uni-packing-wgt

文章目录 背景介绍安装与使用 背景介绍 由于官方的HBuilderX编译器打包wgt每次都要手动的操作有些繁琐,也不支持多环境打包,在开发阶段与原生项目交互调试是极其不方便。而uni-packing-wgt正好可以解决这些问题。 uni-packing-wgt是uniapp跨平台多环境资源打包、调试、发布的插件工具。业内首款开源的wgt多环境打包插件。 主要特性: 支持同

前端vite+vue3——利用环境变量和路由区分h5、pc模块打包(从0到1)

⭐前言 大家好,我是yma16,本文分享 前端vite+vue3——利用环境变量和路由对前端区分h5和pc模块打包(从0到1)。 背景: 前端本地开发pc和h5的项目,发布时需要区分开h5和pc的页面 vite Vite 通过在一开始将应用中的模块区分为 依赖 和 源码 两类,改进了开发服务器启动时间。 依赖 大多为在开发时不会变动的纯 JavaScript。一些较大的依赖(

C#.net6.0+Vue+Ant-Design智慧医院手术麻醉系统源码 手术麻醉软件信息化管理系统 麻醉文书祥解

C#.net6.0+Vue+Ant-Design智慧医院手术麻醉系统源码  手术麻醉软件信息化管理系统 麻醉文书祥解 医护人员通过手麻信息系统可以进行手术的预约申请、受理、安排,从门诊医生下医嘱到发起手术申请、护士长审核通过,均实现了全流程信息化管理,大大减少了跨科室、跨部门的沟通成本和时间成本。 麻醉文书是整个医疗文书的重要组成部分,是对患者麻醉过程中所有情况的全面实时记录,麻醉医生必须