您當前位置>首頁 » 新聞資訊 » 技(jì)術(shù)分(fēn)享 >
Android批量生(shēng)成渠道(dào)包
發表時(shí)間(jiān):2020-11-13
發布人(rén):葵宇科(kē)技(jì)
浏覽次數(shù):50
1、在www.apache.org上(shàng)下(xià)載ant并在自(zì)己★ Ω₹計(jì)算(suàn)機(jī)上(shàng)配置Ant的(de)運行(xíng)環境(ε☆→我的(de)資源中共享了(le)從(cóng)Apache下(xià)載的(de)ant包,大↓₩£(dà)家(jiā)也(yě)可(kě)以自(zì)己去(qù)官網下(≠•≠σxià)載)
資源地(dì)址:http://dα←$"ownload.csdn.net/detail/xiogjie_67/833637↓≤δ•9
[img]http://img.b∑★ λlog.csdn.net/20150107111703128?waterm↓±↑ ark/2/text/aHR0cDovL2Jsb2cuY3Nkbi←Ωε÷5uZXQvcWlueXVueWluZw==/font/5a6L5L2T$ ≥§/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/±™§gravity/Center
[img]http://img.blog.csdn.net/201501071117γ↕∏32908?watermark/2/text/aHR0cDov♣↕€L2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/font "/5a6L5L2T/fontsize/400/fill/I0JBQk "FCMA==/dissolve/70/gravity/Center
2、檢測是(shì)否安裝成功
開(kāi)始——>運行(xíng)——cmd——輸入ant¥÷回車(chē),如(rú)果出現(xiàn)以下(xià)提示,則™↕¥表示Ant環境設置已經配置好(hǎo)
[img]http://img.blog.csdn.net/20150107112156>♣δ∞892?watermark/2/text/aHR0cDov←•L2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/f∏↔ ont/5a6L5L2T/fontsize/400/f≤ 'ill/I0JBQkFCMA==/dissolve/70/gr€₹avity/Center
3、為(wèi)了(le)能(néng)讓ant能(néng)σ×批量生(shēng)成android的(de)apk文(wén)♥Ω¥件(jiàn),需要(yào)将ant-contrib-1.→÷0b3.jar(我的(de)資源中有(yǒu)此文(wé$αn)件(jiàn)可(kě)下(xià)載http://download.cs↔↕dn.net/detail/xiogjie_67/8γ•¶336247)文(wén)件(jiàn)放(fàng)到(dào→β∏)ant的(de)lib目錄中去(qù)
[img]http://img.blog.csdn.netγεγ /20150107112938184?watermark/2/text/πφ©aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcWlueXVueWluZw==/font"'<★/5a6L5L2T/fontsize/400/fill/I0JBQkφ∑β♠FCMA==/dissolve/70/gravity/Centα'•er
4、在Eclipse中指定Ant目錄(不(bù)要(yào)用(÷≤©$yòng)Eclipse自(zì)帶的(de)Ant)Win≥♥dow——>prefercens
[img]http://img.blog.csdn.ne✔±t/20150107113340874?watermark/2/text/aHR0cDovL2J♣™'sb2cuY3Nkbi5uZXQvcWlueXVueWluZw= ☆γ=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/di♦≤ssolve/70/gravity/Center
5、創建Android測試批量打包工(gōng)程
在工(gōng)程下(xià)創建幾個(gè)文(wén)件(jiàn):(也(yě)就(jiù®→÷)是(shì)項目的(de)根目錄下(xià),與src、res是(shì)平級的(★β£₩de)關系)
(1)build.xml
(2)local.properties
(3)ant.properties
說(shuō)明(míng)一(yī)下(xià),這(zhè)三個(gè)™δ文(wén)件(jiàn)的(de)關系,build.xml文(wén)件(jiàn)是(shì₽↑)最主要(yào)的(de)文(wén)件(jiàn),local.proε™✔perties與ant.properties文(wén)件( ♠™Ωjiàn)是(shì)build.xml中引用(yòng)$$✘的(de)文(wén)件(jiàn),也(yě)就(jiù)是(•≥shì)一(yī)些(xiē)變量的(de)設置主要(yào)是(shì)在這(zhè)兩個<÷∏(gè)文(wén)件(jiàn)當中設置。
源碼分(fēn)别如(rú)下(xià):
build.xml
<?xml version="1.0"¶≤ encoding="UTF-8"?>
<!-- 項目名稱Cr'↕∞eateApk,可(kě)用(yòng)全局替換為(wèi)當前項目名稱 -->
&l♠®×£t;project
name="CreateApk"
d≈ ♥efault="deploy" >
∑★✔
<!--
The local.p©δ↔roperties file is created and upd∑®↔☆ated by the 'android' tool.
÷↕ It contains the path to the ≤≠←•SDK. It should *NOT* be checked int¶©o
Version Control ★Systems.
-->
<property file= ↑∞"local.properties&quo☆✔∑♦t; />
<!--
Thε±e ant.properties file can be >≤γ<created by you. It is only edited by the
± 'android' tool &←to add properties to it.
This i±€s the place to change some Ant÷♦★ specific build properties.
Here Ωare some properties you may want to change/updat •↑e:
source.dir
The€> name of the source directory. Default is ✘<←39;src'.
out.dir
Th₩π♣e name of the output directory. D£∞efault is 'bin'.
✘¶αδ
For other overrida≠γ★®ble properties, look at the beginning of the rul♦∑es
files in the SDK, at t ¶↔ools/ant/build.xml
Properties rela✔↕ted to the SDK location or the project ta≤✔rget should
be updated using the 'an∏♣ droid' tool with the 'upda≠∏☆te' action.
This file is an integ§®ral part of the build system for your¥₽ ←
application and should be checked ✔ into Version Control Systems.
<≠> -->
<property♥ ε file="ant.properties" /♦π↑>
<!--
The project.prope↔ γrties 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.proper£ε♣✔ties
(or in .classpath for Ec±α±¥lipse projects).
This file is an inte₩¥gral part of the build system foΩr your
application and shoul≈≥πd be checked into Version Conπλ'✘trol Systems.
-->
☆λ <loadproperties srcFile="project.prop♦ ★δerties" />
<!-- q♦σuick check on sdk.dir -->
♣←≠
<fail
message="s♦←σ←dk.dir is missing. Make sure to g♣φ♣βenerate local.properties using 'android updatσ₹™e project' or to injec₽∞t it through an env var&quo©¶§t;
unless="sdk.dir" →↔♣ />
<!--
extensio•"↑n targets. Uncomment the one↓♣s where you want to do cus♠<¥tom work
in between standard targets
±"-->
<!--
<target na•♠ me="-pre-build">
</ta≈↔÷rget>
<target name="-pre-compi¥¶le">
</targ↕δ↓et>
<target name="☆¶ε-post-compile">
</target&↔₽gt;
-->
<!--
¥∑ Import the actual buil<£₩d file.
To customize existing§±β targets, there are two options:
- C↔ ♠≤ustomize only one target:
- c≤®opy/paste the target into this file, *b÷₽€efore* the
<import> task.
±Ω¶ - customize it to your neλ★↔≠eds.
- Customize the who®✘¥le content of build.xml
-♠γ∑ copy/paste the content of the rules∞§ files (minus the top node)
in♦γto this file, replacing the <import> tas<±∑k.
- customize to ∑∑¥<your needs.
***********************
> ****** IMPORTANT ******
₩ & ********************∏₹≥***
In all cases you must update tβ♠↓↓he value of version-tag below to read 'cuλΩstom' instead of an integer,∞↔↑♠
in order to avoid having your file bβ↕®e overridden by tools such as λ≠±"android update project"
-->
γφ§± <!-- version-tag: 1 --≠φ>
<taskdef resource="net/sf/a↕₹©ntcontrib/antcontrib.properti•'πes" >
<classpath>
∏"¶ <pathelement location="D:/ant/libα±∞£/ant-contrib-1.0b3.jar" />
</ ↕<classpath>
</taskdef>
βφ✔≤
<import file="${s© ★€dk.dir}/tools/ant/build.xml" />
α€α↔
<target name="deploy"•↕↕; >
<foreach
¥←☆ delimiter=","
¶÷↕" list="${market_channels}"÷ ♠
param="channel&qπ♥★uot;
target="modify_manifest&quo™≠Ωt; >
</foreaλ↓ch>
</target>
γ×<target name="modify_manifest&$ ©quot; >
<!-- <rep≤ •laceregexp 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.createapπ≥✘←k ant.project.name=CreateApk jav¶δ"₽a.encoding=utf-8 out.absolute.di<≈¶r=e:/apk/compile gos.path=e:/apπ k/createapk key.store=D:/keystore/key.keystoreγ→ key.store.password=hy123456 key.☆Ωalias=china key.alias.password=hy12345σ♠6 app_version=1.0.0 market_channels=1001,1002 p♣δ™→ublish.date=2015-1-7
釋意如(rú)下(xià):
a、程序包名
b、項目名稱
c、項目編碼
d、臨時(shí)文(wén)件(jiàn)存放(fàng)位置
e、apk文(wén)件(jiàn)存放(fàng)位置
f、秘鑰所在位置
g、秘鑰密碼
h、秘鑰别名
i、别名密碼
j、版本
k、渠道(dào)名稱,要(yào)以逗号分(fēn)隔★→,必須在一(yī)行(xíng)內(nèi)
l、發布日(rì)期
6、運行(xíng)與生(shēng)成
(1$ δ∏)檢查自(zì)己配置的(de)那(nà)些(xiē)個(gè)目©≥₽錄在本地(dì)磁盤中是(shì)否已經創建好(hǎo)♦λ∏∏了(le)文(wén)件(jiàn)夾
∏ (2)檢查build.xml文(wén)件(jiàn)中設置π 與引用(yòng)的(de)文(wén)件(jiàn)(loc↔al.properties、ant.properties)是(shì)否準備好(hǎo)
(3)右擊buil$γ↓d.xml文(wén)件(jiàn)——>run as ——> ant build
7、示例代碼源文(wén)件(jiàn)下(xià)載地(dì)址
http://download.cs§✔ ₽dn.net/detail/xiogjie_67/8336267








