知識
不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價值,我們在追求其視覺表現(xiàn)的同時,更側(cè)重于功能的便捷,營銷的便利,運營的高效,讓網(wǎng)站成為營銷工具,讓軟件能切實提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序為后期升級提供便捷的支持!
Android批量生成渠道包
發(fā)表時間:2020-11-13
發(fā)布人:葵宇科技
瀏覽次數(shù):45
1、在www.apache.org上下載ant并在自己計算機上配置Ant的運行環(huán)境(我的資源中共享了從Apache下載的ant包,大家也可以自己去官網(wǎng)下載)
資源地址:http://download.csdn.net/detail/xiogjie_67/8336379
[img]http://img.blog.csdn.net/20150107111703128?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
[img]http://img.blog.csdn.net/20150107111732908?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
2、檢測是否安裝成功
開始——>運行——cmd——輸入ant回車,如果出現(xiàn)以下提示,則表示Ant環(huán)境設(shè)置已經(jīng)配置好
[img]http://img.blog.csdn.net/20150107112156892?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
3、為了能讓ant能批量生成android的apk文件,需要將ant-contrib-1.0b3.jar(我的資源中有此文件可下載http://download.csdn.net/detail/xiogjie_67/8336247)文件放到ant的lib目錄中去
[img]http://img.blog.csdn.net/20150107112938184?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
4、在Eclipse中指定Ant目錄(不要用Eclipse自帶的Ant)Window——>prefercens
[img]http://img.blog.csdn.net/20150107113340874?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
5、創(chuàng)建Android測試批量打包工程
在工程下創(chuàng)建幾個文件:(也就是項目的根目錄下,與src、res是平級的關(guān)系)
(1)build.xml
(2)local.properties
(3)ant.properties
說明一下,這三個文件的關(guān)系,build.xml文件是最主要的文件,local.properties與ant.properties文件是build.xml中引用的文件,也就是一些變量的設(shè)置主要是在這兩個文件當中設(shè)置。
源碼分別如下:
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=http://www.sjsjw.com/100/000593MYM004194/"(.*)"" replace=""/> -->
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、渠道名稱,要以逗號分隔,必須在一行內(nèi)
l、發(fā)布日期
6、運行與生成
(1)檢查自己配置的那些個目錄在本地磁盤中是否已經(jīng)創(chuàng)建好了文件夾
(2)檢查build.xml文件中設(shè)置與引用的文件(local.properties、ant.properties)是否準備好
(3)右擊build.xml文件——>run as ——> ant build
7、示例代碼源文件下載地址
http://download.csdn.net/detail/xiogjie_67/8336267
相關(guān)案例查看更多
相關(guān)閱讀
- 小程序定制開發(fā)
- 云南企業(yè)網(wǎng)站
- 花農(nóng)小程序
- 云南網(wǎng)站建設(shè)列表網(wǎng)
- 小程序退款
- 網(wǎng)站建設(shè)方案 doc
- 云南省建設(shè)廳網(wǎng)站官網(wǎng)
- typescript
- 紅河小程序開發(fā)
- 網(wǎng)站開發(fā)公司哪家好
- 保險網(wǎng)站建設(shè)公司
- 百度小程序開發(fā)公司
- 云南網(wǎng)站建設(shè)百度
- 云南網(wǎng)站建設(shè)哪家公司好
- 云南網(wǎng)站建設(shè)
- 昆明小程序定制開發(fā)
- 云南省建設(shè)廳網(wǎng)站
- 搜索排名
- 昆明小程序哪家好
- 汽車回收管理系統(tǒng)
- 云南網(wǎng)站建設(shè)首頁
- 英文網(wǎng)站建設(shè)公司
- 昆明網(wǎng)站設(shè)計
- 云南小程序被騙
- 汽車報廢軟件
- 小程序開發(fā)排名前十名
- 網(wǎng)站優(yōu)化哪家好
- 小程序用戶登錄
- 江蘇小程序開發(fā)
- 云南小程序開發(fā)公司