Android批量生成渠道包

1、在www.apache.org上下载ant并在自己计算机上配置Ant的运行环境(我的资源中共享了从Apache下载的ant包,大家也可以自己去官网下载)

2、检测是否安装成功

开始——>运行——cmd——输入ant回车,如果出现以下提示,则表示Ant环境设置已经配置好

3、为了能让ant能批量生成android的apk文件,需要将ant-contrib-1.0b3.jar(我的资源中有此文件可下载)文件放到ant的lib目录中去

4、在Eclipse中指定Ant目录(不要用Eclipse自带的Ant)Window——>prefercens

5、创建Android测试批量打包工程

在工程下创建几个文件:(也就是项目的根目录下,与src、res是平级的关系)

(1)build.xml

(2)local.properties

(3)ant.properties

说明一下,这三个文件的关系,build.xml文件是最主要的文件,local.properties与ant.properties文件是build.xml中引用的文件,也就是一些变量的设置主要是在这两个文件当中设置。

源码分别如下:

build.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- 项目名称CreateApk,可用全局替换为当前项目名称 -->
<project
    name="CreateApk"
    default="deploy" >

    <!--
         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" />

    <!--
         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 an env var"
        unless="sdk.dir" />

    <!--
     extension targets. Uncomment the ones where you want to do custom work
     in between standard targets
    -->
    <!--
    <target name="-pre-build">
    </target>
    <target name="-pre-compile">
    </target>
    <target name="-post-compile">
    </target>
    -->
    <!--
         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 -->

    <taskdef resource="net/sf/antcontrib/antcontrib.properties" >
        <classpath>
            <pathelement location="D:/ant/lib/ant-contrib-1.0b3.jar" />
        </classpath>
    </taskdef>

    <import file="${sdk.dir}/tools/ant/build.xml" />

    <target name="deploy" >

        <foreach
            delimiter=","
            list="${market_channels}"
            param="channel"
            target="modify_manifest" >
        </foreach>
    </target>

    <target name="modify_manifest" >

        <!-- <replaceregexp file="AndroidManifest.xml" encoding="utf-8" match="android:value="(.*)"" replace=""/> -->

        <replaceregexp
            byline="false"
            flags="g" >

            <regexp pattern="android:name="UMENG_CHANNEL" android:value="(.*)"" />

            <substitution expression="android:name="UMENG_CHANNEL" android:value="${channel}"" />

            <fileset
                dir=""
                includes="AndroidManifest.xml" />
        </replaceregexp>

        <!-- <property  name="out.release.file" value="${out.absolute.dir}/${channel}.apk"/> -->

        <antcall target="release" />

        <copy tofile="${gos.path}/${ant.project.name}_${publish.date}_${channel}.apk" >
            <fileset
                dir="${out.absolute.dir}/"
                includes="${ant.project.name}-release.apk" />
        </copy>

        <delete includeEmptyDirs="true" >
            <fileset
                dir="${out.absolute.dir}"
                includes="**/*" />
        </delete>

        <echo message="=============生成完一个APK==============" />
    </target>

</project>

local.propertieslocal.properties

sdk.dir=d:/android-sdk-windows

ant.properties

application.package=com.test.createapk
ant.project.name=CreateApk
java.encoding=utf-8
out.absolute.dir=e:/apk/compile
gos.path=e:/apk/createapk
key.store=D:/keystore/key.keystore
key.store.password=hy123456
key.alias=china
key.alias.password=hy123456
app_version=1.0.0
market_channels=1001,1002
publish.date=2015-1-7

释意如下:

a、程序包名

b、项目名称

c、项目编码

d、临时文件存放位置

e、apk文件存放位置

f、秘钥所在位置

g、秘钥密码

h、秘钥别名

i、别名密码

j、版本

k、渠道名称,要以逗号分隔,必须在一行内

l、发布日期

6、运行与生成

(1)检查自己配置的那些个目录在本地磁盘中是否已经创建好了文件夹

(2)检查build.xml文件中设置与引用的文件(local.properties、ant.properties)是否准备好

(3)右击build.xml文件——>run as ——> ant build

时间: 2024-08-02 22:22:48

Android批量生成渠道包的相关文章

Android应用发布的准备——生成渠道包

我们需要使用一个变量标明该app的渠道,通常我们可以在manifest中的application节点下声明,如下. <meta-data android:name="CHANNEL_NAME" android:value="CHANNEL_VALUE" /> 然后将CHANNEL_VALUE的值替换成对应的渠道名.我们可以使用gradle的flavor替我们完成 productFlavors { wandoujia {} qihu360 {} baidu

Unity3D脚本批量打包渠道包

最近在研究Unity3D脚本批量打包,比如在Android平台下各种不同分辨率和不同内存大小的机器,可能还有不同的渠道包,不同渠道可能用的SDK都不一样,这一切的一切都表明你的代码无法做到自适应的,除非批量打包提供各个平台的预定义标签#define . Unity默认提供了一些预定义标签如: UNITY_EDITOR  : 编辑器模式下. UNITY_STANDALONE:PC Mac Linux模型下. UNITY_IPHONE:IOS模式下. UNITY_ANDROID:ANDROID模式下

iOS使用脚本批量打渠道包

最近我们接到了新的需求,需要打出类似xx001-xx100共100个这样的ipa渠道包,不需要签名.(这批ipa包后续会用企业证书签名,不会影响AppStore的) 这些包所有的功能.内容都是一样的,区别在于不同的包在统计.连接我们服务器时会提供一个不同的字符串标示. 如果按照常规的打包方式,我们需要不断的修改工程中的值,然后一个个打包……这种毫无技术含量的活怎么能忍受! 简单思考之后可以想到,我们可以通过使用shell脚本来实现批量打包,渠道信息可以保存在应用的info.plist里面. 批量

使用python判断Android自动化的渠道包是否全部打完

Android客户端测试上线总会有很多的渠道包,渠道的打包可是使用自动化,但是每次打完都是好几十个或者几百个apk,很南确定是不是所有的渠道都已经打完,所以就有了下面的一段代码,主要就是为了检查是否将所有的渠道包打包完毕: # coding=utf-8 import os import xlrd #获取给定excel列表中的所有渠道号 def add_Qudao_Name(): data=xlrd.open_workbook(excel_path) table=data.sheets()[0]

android studio生成aar包并在其他工程引用aar包

1.aar包是android studio下打包android工程中src.res.lib后生成的aar文件,aar包导入其他android studio 工程后,其他工程可以方便引用源码和资源文件 2.生成aar包步骤: ①.用android studio打开一个工程,然后新建一个Module,新建Module时候选择Android Library,后面按新建普通工程操作 ②.新建Module 类型为android Library 后如下图所示 ③.在新建的Module中编写完代码后,接下来编

批量打渠道包

最近要进行打包全自动化,把打渠道包的功能也给运营来做,所以要把打渠道包的事情转移到服务器上, 默认 本机支持如下命令:java,7z,zipalign*.keystore 和 SignApk.jar 在 ANDROID_HOME\tools\ 文件夹下参数1:工作目录,参数2:源apk路径useage: ./channelbuild.sh D:\\ C:\\Users\\13051041\\Desktop\\sign\\test.apk注意你需要设置下keystore的位置和渠道号 #!/bin

Android Studio 生成aar包,并在其他项目中引用

1.新建Module 2.作为library来使用 3.在这个library写需要独立出来的东西 4.重新编译工程 5.切换到Project模式查看aar包,生成成功~ 6.引用方法,切换到Project模式,将arr包放到libs库中 7.gradle添加以下代码 repositories { flatDir { dirs 'libs' // 申明本地库 } } compile(name: 'mylibrary-debug', ext: 'aar') // 添加本地库 8.引用aar代码 9.

Android批量验证渠道、版本号(Linux版)

功能:可校验单个或目录下所有apk文件的渠道号.版本号(Linux版本)使用说明:1.copy需要校验的apk文件到VerifyChannelVersion目录下2../VerifyChannelVersion运行 3.输入apk的版本号(apk中AndroidManifest.xml的versionName值)4.如果VerifyChannelVersion目录下生成VerifyChannelVersionLog.txt文件, 则说明有异常,具体异常请查看VerifyChannelVersio

android工程生成jar包

============问题描述============ eclipse里面工程太多,不想再把工程导入到eclipse里面,有没有办法在命令行打包出jar包? ============解决方案1============ eclipse -> file -> export 选jar文件不就行了.