The so-called bulk packaging essence is: Just dynamically modify the Channel_valuein the Androidmanifest.xml file, add the channel name you need and repackage it into a new channel package.
Ideas
1. Export an unsigned apk package, where the channel number is configured as.
2. Unzip the APK package with Apktool
3. Modify Channel_value according to channel number
4. RePack with Apktool as an unsigned apk package
5. Sign the unsigned apk package
To use the prompt steps:
First, download the Python installation package, Python 2.7.9:https://www.python.org/downloads/directly run a fool-like installation, just a little attention to the installation of the path.
For example I was installed in D:\Python\Python27, then add D:\Python\Python27 in My Computer environment variable path;
Open cmd and enter Python to see the version information of Python normally, the Python installation is successful.
Second, find the path of the maketool.py in the running terminal, and enter the command: Python maketool.py can be successfully packaged in bulk
Organizational structure such as:
On the basis of the predecessors of the extra Aapt.exe and Apktool.bat files, if no aapt.exe will be reported Jarsigner is not a hint of internal command OH.
Where channel is the funnel number list:
360
91
Aliyun
Android
Anguanjia
Appchina
Gfan
goapk
hiapk
Nduoa
NearMe
Tencent
Wandoujia
Xiaomi
The signature file for the test project is placed in the KeyStore folder Apktest.keystore
APKTEST.APK is an unsigned apk package
Here's the most important maketool.py file.
#!/usr/bin/python# coding=utf-8import osimport shutildef readchannelfile (filename): f = file (filename) while True: line = F.readline (). strip (' \ n ') If Len (line) = = 0:break Else:channelList.appen D (line); F.close () def backupmanifest (): If Os.path.exists ('./androidmanifest.xml '): Os.remove ('./androidmanifest.xml ') Manifestpath = './temp/androidmanifest.xml ' Shutil.copyfile (Manifestpath, './androidmanifest.xml ') def ModifyChannel (value): Tempxml = ' F = File ('./androidmanifest.xml ') for line in F:if line.find (' Channel_value ') > 0:line = Line.replace (' Channel_value ', value) Tempxml + = line F.close () output = open ('./temp/and Roidmanifest.xml ', ' W ') Output.write (tempxml) output.close () unsignapk = R './bin/%s_%s_unsigned.apk '% (easyNa Me, value) Cmdpack = R ' Java-jar Apktool.jar B temp%s '% (unsignapk) Os.system (cmdpack) Signedjar = R './bin/% s_%s_signed.apk'% (easyname, value) Unsignedjar = R './bin/%s_%s_unsigned.apk '% (easyname, value) cmd_sign = R ' jarsigner-verbose-k Eystore%s-storepass%s-signedjar%s%s '% (KeyStore, Storepass, Signedjar, Unsignedjar, Alianame) Os.system (cmd_si GN) Os.remove (Unsignedjar); Channellist = []apkname = ' apktest.apk ' easyname = Apkname.split ('. apk ') [0]keystore= './keystore/apktest.keystore ' storepass= ' 123456 ' alianame= ' Apktest.keystore ' output_apk_dir= "./bin" if Os.path.exists (output_apk_dir): Shutil.rmtree (Output_apk_dir) readchannelfile ('./channel ') print '--------------------your channel values---------- ----------' print ' Channel list: ', channellistcmdextract = R ' Java-jar Apktool.jar d-f-S%s temp '% (apkname) Os.system (c mdextract) Backupmanifest () for channel in Channellist:modifychannel (channel) if Os.path.exists ('./temp '): shutil.rmtr EE ('./temp ') if Os.path.exists ('./androidmanifest.xml '): Os.remove ('./androidmanifest.xml ') print '---------------- ----Done--------------------'
Execution is also very simple to run CMD into the terminal and switch path to maketool.py file path D:\batch_make_tool\batch_make_tool, execute Python maketool.py can
After execution, the bin folder is generated under the folder, according to the signature folder in each market.
My_batch_apktool.zip Download: http://download.csdn.net/detail/etmanwenhan/8493739
Reference: http://blog.csdn.net/luck_apple/article/details/8634572
Android Bulk Packaging tool-python implementation