CN107844301A - A kind of Android application channel closes bag method and device - Google Patents

A kind of Android application channel closes bag method and device Download PDF

Info

Publication number
CN107844301A
CN107844301A CN201711317520.5A CN201711317520A CN107844301A CN 107844301 A CN107844301 A CN 107844301A CN 201711317520 A CN201711317520 A CN 201711317520A CN 107844301 A CN107844301 A CN 107844301A
Authority
CN
China
Prior art keywords
bag
file
main bag
resource
main
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
CN201711317520.5A
Other languages
Chinese (zh)
Inventor
陶杰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Snail Digital Technology Co Ltd
Original Assignee
Suzhou Snail Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Snail Digital Technology Co Ltd filed Critical Suzhou Snail Digital Technology Co Ltd
Priority to CN201711317520.5A priority Critical patent/CN107844301A/en
Publication of CN107844301A publication Critical patent/CN107844301A/en
Withdrawn legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

A kind of Android application channel closes bag method and device, and methods described includes step:Obtain resource, code and the configuration file of main bag and attached bag;The bag name of renaming main bag, and the bag name path of main bag and attached bag;The resource file of attached bag is merged into main bag, generation merges the main bag of resource file;The code file of attached bag is merged into main bag;The configuration file of attached bag is merged into main bag, and the configuration file of modification main bag;Main bag catalogue generation apk is compiled, and is signed, serialized.The Android application channel of the present invention closes bag method and device, can simplify channel promotion flow and largely saving development time and error rate is very low.

Description

A kind of Android application channel closes bag method and device
Technical field
The present invention relates to communication technique field, and bag method and device is closed more particularly to a kind of Android application channel.
Background technology
Game company wants to promote the hand trip product of oneself, and it is to have to remove popularizing action by every company operation ability of oneself Limit, coverage rate is not very wide.But also have some companies do not do hand trip, their main core be do apply popularization, Game, instrument etc., and have very high attention rate and visit capacity inside user group, it is referred to as distributor.One needs Promote, one is promoted, and the emphasis of problem is how to be linked into others' channel platform to be promoted.Distributor is usually There is provided what SDK was docked, there are the example of docking, mating interface document, docking debugging, SDK document information in the inside.Dock channel The SDK of business needs special program to be docked, debugged, tested, and this flow is got off, and may take up several days to one week Time, the distributor of access can also deal with, if a hand trip product is very hot, be inscribed in the extremely short time less If entering tens or even individual channel up to a hundred, that is not just several programmers, and taking several weeks can dock what is completed.
In existing technology, a kind of conventional method is that company oneself encapsulates the SDK of distributor, writes a public JAR Storehouse, a test event is then established, to test the functions such as the login of game, payment, this JAR storehouse is finally supplied to game Project, is added in projects and goes, and the programmer for then also needing to project adds the interface of docking in code, and modification is each The ID and KEY of docking channel are tested again.Another method is then, then writes a script, batch modification channel ID and KEY, the introducing engineering code JAVA of batch, APK is compiled in script, beats signature, is then tested.
In the above described two methods, hand trip project carries out channel docking and all can't steer clear of the source code of game, and needs hand to swim The people of project participates in entering to carry out operation completion docking, to some degree, strictly improves many efficiency, but do not have There is the time for fundamentally discharging hand trip project procedure person, a key is docked and plays games and be totally separated from out.
Therefore need an easy method to optimize this process, that is, have the docking that special people does channel, then handle The APK of trip and the SDK of distributor are dynamically merged, and SDK functional test gives special messenger and goes to test, channel and game point Leave and, the docking of channel need not be concerned about by playing games, and that does channel docking also not go care to play.Therefore, how to realize APK and SDK merging just becomes the emphasis Key technique problem for needing solve.
The content of the invention
In order to solve the shortcomings of the prior art, it is an object of the invention to provide a kind of Android application channel to close Bao Fang Method and device, a bonding is carried out to APK and SDK and is wrapped, channel and applying is separated, make to do apply need not be concerned about channel Docking, do channel docking also not go be concerned about apply.
To achieve the above object, Android application channel provided by the invention closes bag method, comprises the following steps:
Obtain resource, code and the configuration file of main bag and attached bag;
The bag name of renaming main bag, and the bag name path of main bag and attached bag;
The resource file of attached bag is merged into main bag, generation merges the main bag of resource file;
The code file of attached bag is merged into main bag;
The configuration file of attached bag is merged into main bag, and the configuration file of modification main bag;
Main bag catalogue generation apk is compiled, and is signed, serialized.
Further, described that the resource file of attached bag is merged into main bag, generation merges the step of the main bag of resource file Before rapid, step is performed:Generate the index file of main bag and the respective resource file of attached bag.
Further, described that the resource file of attached bag is merged into main bag, generation merges the step of the main bag of resource file After rapid, step is performed:Generation merges the index file of the resource file of the main bag of resource file, and serializes resource ID.
Further, before the step code file of attached bag being merged into main bag, step is performed:Modification is female Wrap, the attribute information of the code file of attached bag.
Further, the compiling main bag catalogue generation apk, and the step of signed, serialized before, perform step Suddenly:Advertiser ID is added to the configuration file of main bag.
Further, if a channel has multiple advertiser ID, circulation performs the addition advertiser ID and arrives main bag The step of configuration file, and the compiling main bag catalogue generation apk, and the step of signed, serialized.
Further, if once merging multiple support channels, circulation performs the Android application channel and closed described in bag method The step of.
To achieve the above object, Android application channel provided by the invention closes bag apparatus, including:Apk decompilings module, bag Name modified module, resource file merging module, code file merging module, configuration file modified module and apk collectors, its In,
The apk decompilings module, for obtaining resource, code and the configuration file of main bag and attached bag;
The bag name modified module, for the bag name of renaming main bag, and the bag name path of main bag and attached bag;
The resource file merging module, for the resource file of attached bag to be merged into main bag, generation merges resource file Main bag;
The code file merging module, for the code file of attached bag to be merged into main bag;
The configuration file modified module, for the configuration file of attached bag to be merged into main bag, and the configuration of modification main bag File;
The apk collectors, for compiling main bag catalogue generation apk, and signed, serialized.
Further, the resource file merging module, it is additionally operable to generate the rope of main bag and the respective resource file of attached bag Quotation part, and generation merge the index file of the resource file of the main bag of resource file, and serialize resource ID.
Further, the configuration file modified module, it is additionally operable to add advertiser ID to the configuration file of main bag.
The Android application channel of the present invention closes bag method and device, can simplify channel promotion flow and largely save exploitation Time and error rate is very low.
Other features and advantages of the present invention will be illustrated in the following description, also, partly becomes from specification Obtain it is clear that or being understood by implementing the present invention.
Brief description of the drawings
Accompanying drawing is used for providing a further understanding of the present invention, and a part for constitution instruction, and with the present invention's Embodiment together, for explaining the present invention, is not construed as limiting the invention.In the accompanying drawings:
Fig. 1 is to close bag method flow diagram according to the Android application channel of the present invention;
Fig. 2 is to close bag apparatus structure chart according to the Android application channel of the present invention.
Embodiment
The preferred embodiments of the present invention are illustrated below in conjunction with accompanying drawing, it will be appreciated that described herein preferred real Apply example to be merely to illustrate and explain the present invention, be not intended to limit the present invention.
In the examples below, the client apk of each application item exploitation is referred to as main bag, encapsulates channel SDK apk Referred to as attached bag.
Fig. 1 is to close bag method flow diagram according to the Android application channel of the present invention, below with reference to Fig. 1, to the present invention's Android application channel closes bag method and is described in detail.
In step 110, decompiling main bag and attached bag, resource, code and the configuration file of main bag and attached bag are obtained.
In the step, by main bag and attached bag, decompiling is under the catalogue each specified respectively, for example, being respectively [game_ dir]、[channel_dir].First emptied with Windows rd orders if catalogue is sky, used if without catalogue The Windows newly-built catalogues of SHCreateDirectoryEx.And can use apktool.jar apktool.jar d- F package-o [game_dir]/[channel_dir] orders decompiling main bag respectively and attached bag to different files Under.
In step 120, the bag name path of the bag name of renaming main bag, and main bag and attached bag.
In the step, replace in main bag AndroidManifest.xml using bag title and main bag and attached bag Smali files(Code file)In bag name path.One kind of this step is achieved in that:
With the AndroidManifest.xml in main bag after the opening decompiling of xml read methods, xml root nodes are obtained Package attributes obtain original application bag name;Compare with the new bag name of configuration, it is identical, any operation is not done, it is different then first Replace the bag name in AndroidManifest.xml;Then using in CFileFind classes poll traversal main bag and attached bag Smali catalogues list all smali files, and binary mode opens smali files one by one, the path replacement corresponding to bag name Bag name path in all smali files(For example newly wrap entitled com.snailgame.panda.yy and then use com/ Snailgame/panda/yy is replaced), and create catalogue [game_dir/com/snailgame/panda/ corresponding to new bag name Yy], former bag name is corresponded into file copy under catalogue to new bag name with xcopy [dir] [new_dir]/s/e/y/c orders Under corresponding catalogue, catalogue corresponding to former bag name is deleted in then rd/s/q orders.
In step 130, the resource file of attached bag is merged into main bag, generation merges the main bag of resource file.
Before resource file is merged, main bag and the respective R.java of attached bag are generated respectively using aapt.exe tool commands File.For example, use aapt.exe package-f-m-J [game_Rjava_Dir]/[channel_Rjava_Dir] -S [game_dir\res]/ [channel_dir\res] -I [android.jar] -M [game_dir\ AndroidManifest.xml]/[channel_dir AndroidManifest.xml] order generates R.java files respectively To under [game_Rjava_Dir]/[channel_Rjava_Dir].Wherein, R.java files are main bag, the resource file of attached bag Index file.
In the step, when merging resource file, first, the assets catalogues in attached bag are merged into using xcopy orders The assets catalogues of main bag.For example, using xcopy orders will [channel_dir assets] copy to [game_dir Assets] under catalogue:Listed [channel_dir assets] and [game_dir assets] using the circulation of CFileFind classes All Files under catalogue is copied one by one into vector using xcopy orders.Xcopy order attentions take/s/e/y/c ginsengs Number.If configuration be additionally required addition main bag and attached bag resource, it is necessary to which these resources first are individually copied into [channel_ Dir assets] and [game_dir assets] in.
Then, the lib catalogues of attached bag are merged into main bag lib catalogues using xcopy orders.For example, use xcopy orders [channel_dir lib] is copied under [game_dir lib] catalogue:Listed using the circulation of CFileFind classes All Files under [channel_dir lib] and [game_dir lib] catalogue is into vector, using xcopy orders one by one Copy.If [game_dir lib] only has armeabi catalogues, [channel_dir lib] only has armeabi-v7a catalogues, The armeabi catalogues of [game_dir lib] are then only copied to the armeabi-v7a catalogues of [game_dir lib], and deleted Armeabi catalogues;Armeabi catalogues in the armeabi catalogues of [game_dir lib], [channel_dir lib], are needed Armeabi catalogues, the armeabi-v7a catalogues of [game_dir lib] of [game_dir lib] are merged into, Armeabi-v7a catalogues and armeabi catalogues in [channel_dir lib], it is necessary to copy to [game_dir lib] Armeabi-v7a catalogues.Specially treated for x86 catalogues:When [game_dir lib] has an x86 catalogues, and [channel_ Dir lib] there is no x86 catalogues, then the bag after merging just there is no x86 catalogues, it is necessary to delete [game_dir lib] x86 mesh Record.For other catalogues in [game_dir lib]:Only [game_dir lib] and [channel_dir lib] have Other catalogues, just need to copy.
Finally, the res catalogue files in attached bag are merged into the res catalogues of main bag one by one using copy orders, had of the same name Piece file mergence file content.For example, [channel_dir res] is copied into [game_dir res] mesh using xcopy orders Under record:The All Files under [channel_dir res] and [game_dir res] catalogue is listed using the circulation of CFileFind classes Into vector, copied one by one using copy orders.If xml document of the same name occurs in copy, read with binary file Mode merges file content.
After resource file is merged, first, generated using aapt.exe tool commands with the main bag for merging resource file R.java files.Then, reuse reading xml document method and parse former main bag, the R.java files of attached bag and merging respectively The R.java files of the main bag of resource file, resource ID corresponding to the resource name of file are stored in respectively in different map, sequence Rowization resource ID.
For example, use aapt.exe package-f-m-J [game_Rjava_Dir]-S [game_dir res] - I [android.jar]-M [game_dir AndroidManifest.xml] orders generation R.java files are to [unite_ Rjava_Dir] under;Then, binary system reads the R.java files of the main bag of former main bag, attached bag and merging resource file(Three It is individual), and respectively by resource name and resource ID storage into three map, serialize resource ID.
In step 140, the code file of attached bag is merged into main bag.
In the step, first, the R.java files of the main bag of resource file will be merged using binary file reading/writing method, Write according to rule in R.smali and R $ * .smali files, generate new R.smali and R $ * .smali files.
Specifically, [game_dir/res/ is replaced with the resource ID in the R.java for the main bag for merging resource file Value/public.xml] in resource ID, and under poll [game_dir/smali] and [channel_dir/smali] All .smali files, original resource ID is replaced with the resource ID in the R.java for the main bag for merging resource file.
Searching the method for resource ID is, searches const v and const/high16 the v character strings in smali files, goes out This existing character string illustrates to be below resource ID, it is necessary to be replaced it with new resource ID.
Replacement resource ID method is:
1)Resource name and resource ID are parsed according to the R.java of main bag, it is former according to template generation R.smali files, decompiling Some R.smali, three row contents are amended as follows on the basis of original R.smali:
".class public final L";// replace bag title and filename;
" L";The resource name and resource ID// filled out in this braces according to form in R.java pay attention to last Only have branch there is no comma after individual resource class name;
" .line ";// modification line number
2)Resources-type array is parsed according to the R.java of main bag, according to template generation R $ * .smali files, polling resources class number Group establishment file, how many how many individual files of resources-type establishment, class name replace R $ * .smali * as filename.Each text It is as follows comprising the resource in class and resource ID, form in part:
".class public final L";// modification bag name and resource class name(Filename)
" value = L";// modification bag name
" name = ";// modification resource class name
".field public static final ";// addition resource information, each resource is according to this character string+money Source name+":I="+resource ID
" .line ";// modification line number
Then, using xml reading/writing methods, the android of application in the AndroidManifest.xml of main bag is changed: Name attributes:
1)If there is this attribute in main bag, need to take out smali files corresponding to modification.Smali texts corresponding to lookup Part method is:
If application android:Name=" .SnailApp ", then smali is under bag name catalogue: com.snailgame.panda.snail.SnailApp;Otherwise, then [the game_ under com.snail.SnailApp paths dir/smali/com/snail/SnailApp.smali].After finding smali files, the .super roads of smali files are read Footpath, if .super paths are Landroid/app/Application, continue to this file operation;If .super paths It is not Landroid/app/Application, then smali files corresponding to .super paths is continued to search for, until .super roads Untill footpath is Landroid/app/Application.
2)If there is no this attribute in main bag, read the middle AndroidManifest.xml's of attached bag Application android:Name, have, replace and do not operate then.
Finally, after the attribute information that main bag, the code file of attached bag are changed by above-mentioned steps, xcopy orders are used The smali catalogue files of attached bag are merged into the smali catalogues of main bag, if side operator has smali_ more than 65535 Classes2 catalogues, it is also desirable to similarly merge.For example, [channel_dir smali] is copied to using xcopy orders Under [game_dir smali] catalogue, if side operator has smali_classes2 lifes more than 65535 in main bag or attached bag Into also similarly merging.And by newly-generated R.smali and R $ * .smali files, also copy [game_ to xcopy orders Dir/smali] under catalogue corresponding to following bag name.
In step 150, the configuration file of attached bag is merged into main bag, and the configuration file of modification main bag.
In the step, the unknown catalogue files of attached bag are merged into the unknown catalogues of main bag using xcopy orders. For example, [channel_dir unknown] is copied under [game_dir unknown] catalogue using xcopy orders.
The AndroidManifest.xml contents in attached bag are merged into main bag using the method for reading xml document.Example Such as, [channel_dir AndroidManifest.xml] content is merged into [game_ using the method for reading xml document dir\ AndroidManifest.xml].The attribute added if configuring extra needs is also added to [game_ at this moment dir\ AndroidManifest.xml]。
Use the version number in the AndroidManifest.xml of xml reading/writing methods modification main bag and debugging mode.Example Such as, the version number in [game_dir AndroidManifest.xml] is changed using xml reading/writing methods("android: versionCode")And debugging mode("android:debuggable").
Icon icons apply in modification, using xcopy orders by the icon file copies changed of needs to example under icon catalogue Such as [game_dir/res].
Use the apktool.yml files [game_dir/ generated in binary file reading/writing method read step 110 Apktool.yml] and [channel_dir/apktool.ylm] in minSdkVersion and targetSdkVersion, take mother In the apktool.yml files of higher value write-in main bag in bag and attached bag.
Use the apktool.yml files [game_dir/ generated in binary file reading/writing method read step 110 Apktool.yml] and [channel_dir/apktool.ylm] in content under unknownFiles character string braces, will In write-in main bag apktool.yml files in attached bag.
In step 160, addition advertiser ID to main bag configuration file.
In the step, advertiser ID can be added to main bag using xml written documents method In AndroidManifest.xml.For example, advertiser ID is added to [game_dir/ using xml written documents method AndroidManifest.xml] in.If MediaID is configured, then mediaid is changed, is added to if not Under Activity level nodes.For example, meta-data android:Name=" advertiser's title " android:Value=" advertisement Business ID ".
In step 170, compiling main bag catalogue generation apk, and signed, serialized.
In the step, first, main bag catalogue is compiled using apktool.jar orders, generates apk.Order and be: apktool.jar b -f [game_dir] -o unsigned.apk。
Secondly, the apk of generation is signed using SignApk.jar orders.Order and be:java –jar SignApk.jar file.keystore storepassword aliasname aliaspassword unsigned.apk Signed.apk.
Then, the apk after signature is serialized using zipalign orders.Order and be:zipalign -v 4 Signed.apk formally issues .apk.
Finally, the apk that this is formally issued is copied under final catalogue with copy orders, can according to the time+ Media ID Rename files, because the apk of multiple same channels may be generated once.
In step 180, if a channel has multiple advertiser ID, circulation performs step 160-170;If once merge more Individual channel, then circulation perform step 110-170.
Fig. 2 is to close bag apparatus structure chart according to the Android application channel of the present invention, as shown in Fig. 2 the Android of the present invention should Bag apparatus 200 is closed with channel, including:Apk decompilings module 210, bag name modified module 220, resource file merging module 230, Code file merging module 240, configuration file modified module 250 and apk collectors 260, wherein,
Apk decompilings module 210, for decompiling main bag and attached bag, resource, code and the configuration for obtaining main bag and attached bag are literary Part.
Specifically, by main bag and attached bag, decompiling is under the catalogue each specified respectively, for example, being respectively [game_ dir]、[channel_dir].First emptied with Windows rd orders if catalogue is sky, used if without catalogue The Windows newly-built catalogues of SHCreateDirectoryEx.And can use apktool.jar apktool.jar d- F package-o [game_dir]/[channel_dir] orders decompiling main bag respectively and attached bag to different files Under.
Bag name modified module 220, for the bag name of renaming main bag, and the bag name path of main bag and attached bag.
Specifically, replace in main bag AndroidManifest.xml and apply bag title, and main bag and attached bag Smali files(Code file)In bag name path.One kind is achieved in that:
With the AndroidManifest.xml in main bag after the opening decompiling of xml read methods, xml root nodes are obtained Package attributes obtain original application bag name;Compare with the new bag name of configuration, it is identical, any operation is not done, it is different then first Replace the bag name in AndroidManifest.xml;Then using in CFileFind classes poll traversal main bag and attached bag Smali catalogues list all smali files, and binary mode opens smali files one by one, the path replacement corresponding to bag name Bag name path in all smali files(For example newly wrap entitled com.snailgame.panda.yy and then use com/ Snailgame/panda/yy is replaced), and create catalogue [game_dir/com/snailgame/panda/ corresponding to new bag name Yy], former bag name is corresponded into file copy under catalogue to new bag name with xcopy [dir] [new_dir]/s/e/y/c orders Under corresponding catalogue, catalogue corresponding to former bag name is deleted in then rd/s/q orders.
Resource file merging module 230, for the resource file of attached bag to be merged into main bag, generation merges resource file Main bag.
Specifically, before resource file is merged, main bag is generated respectively using aapt.exe tool commands and attached bag is each From R.java files.For example, use aapt.exe package-f-m-J [game_Rjava_Dir]/[channel_ Rjava_Dir] -S [game_dir\res]/ [channel_dir\res] -I [android.jar] -M [game_ Dir AndroidManifest.xml]/[channel_dir AndroidManifest.xml] order generates R.java respectively File is under [game_Rjava_Dir]/[channel_Rjava_Dir].Wherein, R.java files are main bag, the resource of attached bag The index file of file.
When merging resource file, first, the assets catalogues in attached bag are merged into main bag using xcopy orders Assets catalogues.For example, [channel_dir assets] is copied into [game_dir assets] mesh using xcopy orders Under record:The institute under [channel_dir assets] and [game_dir assets] catalogue is listed using the circulation of CFileFind classes There is file into vector, copied one by one using xcopy orders.Xcopy order attentions take/s/e/y/c parameters.If with The main bag for being additionally required addition and attached bag resource are put, it is necessary to be first individually copied to these resources [channel_dir assets] In [game_dir assets].
Then, the lib catalogues of attached bag are merged into main bag lib catalogues using xcopy orders.For example, use xcopy orders [channel_dir lib] is copied under [game_dir lib] catalogue:Listed using the circulation of CFileFind classes All Files under [channel_dir lib] and [game_dir lib] catalogue is into vector, using xcopy orders one by one Copy.If [game_dir lib] only has armeabi catalogues, [channel_dir lib] only has armeabi-v7a catalogues, The armeabi catalogues of [game_dir lib] are then only copied to the armeabi-v7a catalogues of [game_dir lib], and deleted Armeabi catalogues;Armeabi catalogues in the armeabi catalogues of [game_dir lib], [channel_dir lib], are needed Armeabi catalogues, the armeabi-v7a catalogues of [game_dir lib] of [game_dir lib] are merged into, Armeabi-v7a catalogues and armeabi catalogues in [channel_dir lib], it is necessary to copy to [game_dir lib] Armeabi-v7a catalogues.Specially treated for x86 catalogues:When [game_dir lib] has an x86 catalogues, and [channel_ Dir lib] there is no x86 catalogues, then the bag after merging just there is no x86 catalogues, it is necessary to delete [game_dir lib] x86 mesh Record.For other catalogues in [game_dir lib]:Only [game_dir lib] and [channel_dir lib] have Other catalogues, just need to copy.
Finally, the res catalogue files in attached bag are merged into the res catalogues of main bag one by one using copy orders, had of the same name Piece file mergence file content.For example, [channel_dir res] is copied into [game_dir res] mesh using xcopy orders Under record:The All Files under [channel_dir res] and [game_dir res] catalogue is listed using the circulation of CFileFind classes Into vector, copied one by one using copy orders.If xml document of the same name occurs in copy, read with binary file Mode merges file content.
After resource file is merged, first, generated using aapt.exe tool commands with the main bag for merging resource file R.java files.Then, reuse reading xml document method and parse former main bag, the R.java files of attached bag and merging respectively The R.java files of the main bag of resource file, resource ID corresponding to the resource name of file are stored in respectively in different map, sequence Rowization resource ID.
For example, use aapt.exe package-f-m-J [game_Rjava_Dir]-S [game_dir res] - I [android.jar]-M [game_dir AndroidManifest.xml] orders generation R.java files are to [unite_ Rjava_Dir] under;Then, binary system reads the R.java files of the main bag of former main bag, attached bag and merging resource file(Three It is individual), and respectively by resource name and resource ID storage into three map, serialize resource ID.
Code file merging module 240, for the code file of attached bag to be merged into main bag.
Specifically, first, the R.java files of the main bag of resource file will be merged using binary file reading/writing method, Write according to rule in R.smali and R $ * .smali files, generate new R.smali and R $ * .smali files.
For example, replace [game_dir/res/value/ with the resource ID in the R.java for the main bag for merging resource file Public.xml] in resource ID, it is and all under poll [game_dir/smali] and [channel_dir/smali] .smali file, original resource ID is replaced with the resource ID in the R.java for the main bag for merging resource file.
Searching the method for resource ID is, searches const v and const/high16 the v character strings in smali files, goes out This existing character string illustrates to be below resource ID, it is necessary to be replaced it with new resource ID.
Replacement resource ID method is:
1)Resource name and resource ID are parsed according to the R.java of main bag, it is former according to template generation R.smali files, decompiling Some R.smali, three row contents are amended as follows on the basis of original R.smali:
".class public final L";// replace bag title and filename;
" L";The resource name and resource ID// filled out in this braces according to form in R.java pay attention to last Only have branch there is no comma after individual resource class name;
" .line ";// modification line number
2)Resources-type array is parsed according to the R.java of main bag, according to template generation R $ * .smali files, polling resources class number Group establishment file, how many how many individual files of resources-type establishment, class name replace R $ * .smali * as filename.Each text It is as follows comprising the resource in class and resource ID, form in part:
".class public final L";// modification bag name and resource class name(Filename)
" value = L";// modification bag name
" name = ";// modification resource class name
".field public static final ";// addition resource information, each resource is according to this character string+money Source name+":I="+resource ID
" .line ";// modification line number
Then, using xml reading/writing methods, the android of application in the AndroidManifest.xml of main bag is changed: Name attributes:
1)If there is this attribute in main bag, need to take out smali files corresponding to modification.Smali texts corresponding to lookup Part method is:
If application android:Name=" .SnailApp ", then smali is under bag name catalogue: com.snailgame.panda.snail.SnailApp;Otherwise, then [the game_ under com.snail.SnailApp paths dir/smali/com/snail/SnailApp.smali].After finding smali files, the .super roads of smali files are read Footpath, if .super paths are Landroid/app/Application, continue to this file operation;If .super paths It is not Landroid/app/Application, then smali files corresponding to .super paths is continued to search for, until .super roads Untill footpath is Landroid/app/Application.
2)If there is no this attribute in main bag, read the middle AndroidManifest.xml's of attached bag Application android:Name, have, replace and do not operate then.
Finally, after the attribute information that main bag, the code file of attached bag are changed by above-mentioned steps, xcopy orders are used The smali catalogue files of attached bag are merged into the smali catalogues of main bag, if side operator has smali_ more than 65535 Classes2 catalogues, it is also desirable to similarly merge.For example, [channel_dir smali] is copied to using xcopy orders Under [game_dir smali] catalogue, if side operator has smali_classes2 lifes more than 65535 in main bag or attached bag Into also similarly merging.And by newly-generated R.smali and R $ * .smali files, also copy [game_ to xcopy orders Dir/smali] under catalogue corresponding to following bag name.
Configuration file modified module 250, the configuration file of attached bag is merged into main bag, and the configuration text of modification main bag Part.
Specifically, the unknown catalogue files of attached bag are merged into the unknown catalogues of main bag using xcopy orders. For example, [channel_dir unknown] is copied under [game_dir unknown] catalogue using xcopy orders.
The AndroidManifest.xml contents in attached bag are merged into main bag using the method for reading xml document.Example Such as, [channel_dir AndroidManifest.xml] content is merged into [game_ using the method for reading xml document dir\ AndroidManifest.xml].The attribute added if configuring extra needs is also added to [game_ at this moment dir\ AndroidManifest.xml]。
Use the version number in the AndroidManifest.xml of xml reading/writing methods modification main bag and debugging mode.Example Such as, the version number in [game_dir AndroidManifest.xml] is changed using xml reading/writing methods("android: versionCode")And debugging mode("android:debuggable").
Icon icons apply in modification, using xcopy orders by the icon file copies changed of needs to example under icon catalogue Such as [game_dir/res].
Apktool.yml files [the game_ of the generation of apk decompilings module 210 is read using binary file reading/writing method Dir/apktool.yml] and [channel_dir/apktool.ylm] in minSdkVersion and targetSdkVersion, The higher value in main bag and attached bag is taken to write in the apktool.yml files of main bag.
Apktool.yml files [the game_ of the generation of apk decompilings module 210 is read using binary file reading/writing method Dir/apktool.yml] and [channel_dir/apktool.ylm] in it is interior under unknownFiles character string braces Hold, by the write-in main bag apktool.yml files in attached bag.
Apk collectors 260, for compiling main bag catalogue generation apk, and signed, serialized.
Specifically, first, main bag catalogue is compiled using apktool.jar orders, generates apk.Order and be: apktool.jar b -f [game_dir] -o unsigned.apk。
Secondly, the apk of generation is signed using SignApk.jar orders.Order and be:java –jar SignApk.jar file.keystore storepassword aliasname aliaspassword unsigned.apk Signed.apk.
Then, the apk after signature is serialized using zipalign orders.Order and be:zipalign -v 4 Signed.apk formally issues .apk.
Finally, the apk that this is formally issued is copied under final catalogue with copy orders, can according to the time+ Media ID Rename files, because the apk of multiple same channels may be generated once.
Further, configuration file modified module 250, it is additionally operable to add advertiser ID into the configuration file of main bag.
Specifically, advertiser ID can be added to main bag using xml written documents method In AndroidManifest.xml.For example, advertiser ID is added to [game_dir/ using xml written documents method AndroidManifest.xml] in.If MediaID is configured, then mediaid is changed, is added to if not Under Activity level nodes.For example, meta-data android:Name=" advertiser's title " android:Value=" advertisement Business ID ".
Further, Android application channel closes bag apparatus 200 and also included:Channel is set and control module 270, and it is according to preceding State Android application channel and close bag method, control apk decompilings module 210, bag name modified module 220, resource file merging module 230th, code file merging module 240, the execution sequence of configuration file modified module 250 and apk collectors 260 and secondary Number.
In the above-described embodiments, the order or method that each step is used are existing Open-Source Tools or storehouse.Perform order Performed with Windows CreateProcess methods, can so set hiding cmd windows to perform order, and will can order Order performs output result and is redirected to journal file.As for the parameter and directory path needed during it can with QT or MFC writes interface and allows user configuration more intuitive and convenient.
The Android application channel of the present invention closes bag method and apparatus, can simplify channel promotion flow and largely save exploitation Time and error rate is very low.
One of ordinary skill in the art will appreciate that:The preferred embodiments of the present invention are the foregoing is only, and are not had to In the limitation present invention, although the present invention is described in detail with reference to the foregoing embodiments, for those skilled in the art For, its technical scheme that can be still recorded to foregoing embodiments is modified, or which part technical characteristic is entered Row equivalent substitution.Within the spirit and principles of the invention, any modification, equivalent substitution and improvements made etc., all should include Within protection scope of the present invention.

Claims (9)

1. a kind of Android application channel closes bag method, it is characterised in that comprises the following steps:
Obtain resource, code and the configuration file of main bag and attached bag;
The bag name of renaming main bag, and the bag name path of main bag and attached bag;
The resource file of attached bag is merged into main bag, generation merges the main bag of resource file;
The code file of attached bag is merged into main bag;
The configuration file of attached bag is merged into main bag, and the configuration file of modification main bag;
Main bag catalogue generation apk is compiled, and is signed, serialized
Above step is repeated, completes merging by all kinds of means.
2. Android application channel according to claim 1 closes bag method, it is characterised in that the resource file by attached bag Be merged into main bag, generation merge resource file main bag the step of before, perform step:Generate main bag and the respective money of attached bag The index file of source file.
3. Android application channel according to claim 1 closes bag method, it is characterised in that the resource file by attached bag Be merged into main bag, generation merge resource file main bag the step of after, perform step:Generation merges the main bag of resource file Resource file index file, and serialize resource ID.
4. Android application channel according to claim 1 closes bag method, it is characterised in that the code file by attached bag It is merged into before the step in main bag, performs step:Change main bag, the attribute information of the code file of attached bag.
5. Android application channel according to claim 1 closes bag method, it is characterised in that the compiling main bag catalogue generation Apk, and the step of signed, serialized before, perform step:Advertiser ID is added to the configuration file of main bag.
6. Android application channel according to claim 5 closes bag method, it is characterised in that if a channel has multiple advertisements The step of business ID, then the circulation execution addition advertiser ID to main bag configuration file, and the compiling main bag catalogue life Into apk, and the step of signed, serialized.
7. a kind of Android application channel closes bag apparatus, it is characterised in that including:Apk decompilings module, bag name modified module, money Source file merging module, code file merging module, configuration file modified module and apk collectors, wherein,
The apk decompilings module, for obtaining resource, code and the configuration file of main bag and attached bag;
The bag name modified module, for the bag name of renaming main bag, and the bag name path of main bag and attached bag;
The resource file merging module, for the resource file of attached bag to be merged into main bag, generation merges resource file Main bag;
The code file merging module, for the code file of attached bag to be merged into main bag;
The configuration file modified module, for the configuration file of attached bag to be merged into main bag, and the configuration of modification main bag File;
The apk collectors, for compiling main bag catalogue generation apk, and signed, serialized.
8. Android application channel according to claim 7 closes bag apparatus, it is characterised in that the resource file merges mould Block, it is additionally operable to generate the index file of main bag and the respective resource file of attached bag, and generation merges the main bag of resource file The index file of resource file, and serialize resource ID.
9. Android application channel according to claim 7 closes bag apparatus, it is characterised in that the configuration file changes mould Block, it is additionally operable to add advertiser ID to the configuration file of main bag.
CN201711317520.5A 2017-12-12 2017-12-12 A kind of Android application channel closes bag method and device Withdrawn CN107844301A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711317520.5A CN107844301A (en) 2017-12-12 2017-12-12 A kind of Android application channel closes bag method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711317520.5A CN107844301A (en) 2017-12-12 2017-12-12 A kind of Android application channel closes bag method and device

Publications (1)

Publication Number Publication Date
CN107844301A true CN107844301A (en) 2018-03-27

Family

ID=61664858

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711317520.5A Withdrawn CN107844301A (en) 2017-12-12 2017-12-12 A kind of Android application channel closes bag method and device

Country Status (1)

Country Link
CN (1) CN107844301A (en)

Cited By (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108595187A (en) * 2018-03-27 2018-09-28 北京美好人生伙伴信息技术有限公司 Method, device and the storage medium of Android installation kit integrated software development kit
CN108829400A (en) * 2018-05-15 2018-11-16 苏州玩友时代科技股份有限公司 A kind of channel packaging method that iOS need not be compiled repeatedly
CN108829405A (en) * 2018-06-04 2018-11-16 网易(杭州)网络有限公司 The generation method and device of channel packet, storage medium, electronic device
CN109522295A (en) * 2018-11-16 2019-03-26 中国银行股份有限公司 A kind of database object constructs automatically, dispositions method and device
CN109542415A (en) * 2018-11-13 2019-03-29 五八同城信息技术有限公司 The code merging method and relevant device for supporting application program to research and develop parallel
CN109857405A (en) * 2019-02-02 2019-06-07 Oppo广东移动通信有限公司 Compilation Method, device, storage medium and the terminal of application program installation kit
CN110201397A (en) * 2019-06-28 2019-09-06 北京金山安全软件有限公司 Game resource allocation method and device and electronic equipment
CN110457045A (en) * 2019-08-16 2019-11-15 百度在线网络技术(北京)有限公司 Modularization merges Compilation Method, device, equipment and storage medium
CN110941443A (en) * 2019-12-12 2020-03-31 支付宝(杭州)信息技术有限公司 Method and device for modifying file name in SDK and electronic equipment
CN111090425A (en) * 2019-12-12 2020-05-01 支付宝(杭州)信息技术有限公司 Program packaging method and device and electronic equipment
CN111381865A (en) * 2020-04-01 2020-07-07 深圳传趣网络技术有限公司 Packaging method, device and equipment of game application and storage medium
CN111596931A (en) * 2020-05-27 2020-08-28 北京学之途网络科技有限公司 Application program packaging method and device, electronic equipment and readable storage medium
CN111611007A (en) * 2020-05-21 2020-09-01 掌阅科技股份有限公司 Script-based application program installation package packaging method and device
CN112052013A (en) * 2020-08-03 2020-12-08 完美世界(北京)软件科技发展有限公司 Software package generation method and device, storage medium and electronic device
CN112732644A (en) * 2020-12-31 2021-04-30 广州三七网络科技有限公司 Resource index processing method for application program, computer device and storage medium
CN112905170A (en) * 2021-03-09 2021-06-04 百果园技术(新加坡)有限公司 Channel package generation method, device, equipment and storage medium
CN113190263A (en) * 2021-04-21 2021-07-30 宝宝巴士股份有限公司 Method and device for integrating third-party SDK
CN113721929A (en) * 2021-08-11 2021-11-30 安徽帕觅智能科技有限公司 Method for automatically implanting common code into Android App

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160205124A1 (en) * 2015-01-14 2016-07-14 Korea Internet & Security Agency System and method for detecting mobile cyber incident
CN106445509A (en) * 2016-09-09 2017-02-22 厦门雅基软件有限公司 SDK batch quick access tool
CN107402792A (en) * 2017-08-01 2017-11-28 广州视源电子科技股份有限公司 Integrated approach, device, equipment and the storage medium of application software installation kit

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160205124A1 (en) * 2015-01-14 2016-07-14 Korea Internet & Security Agency System and method for detecting mobile cyber incident
CN106445509A (en) * 2016-09-09 2017-02-22 厦门雅基软件有限公司 SDK batch quick access tool
CN107402792A (en) * 2017-08-01 2017-11-28 广州视源电子科技股份有限公司 Integrated approach, device, equipment and the storage medium of application software installation kit

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
CHENJIE19891104: "教你快速高效接入SDK--打包工具的实现(反编译资源动态整合打渠道包)", 《HTTPS://BLOG.CSDN.NET/CHENJIE19891104/ARTICLE/DETAILS/44279379》 *

Cited By (28)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108595187A (en) * 2018-03-27 2018-09-28 北京美好人生伙伴信息技术有限公司 Method, device and the storage medium of Android installation kit integrated software development kit
CN108829400A (en) * 2018-05-15 2018-11-16 苏州玩友时代科技股份有限公司 A kind of channel packaging method that iOS need not be compiled repeatedly
CN108829400B (en) * 2018-05-15 2019-04-26 苏州玩友时代科技股份有限公司 A kind of channel packaging method that iOS need not be compiled repeatedly
CN108829405A (en) * 2018-06-04 2018-11-16 网易(杭州)网络有限公司 The generation method and device of channel packet, storage medium, electronic device
CN108829405B (en) * 2018-06-04 2021-12-21 网易(杭州)网络有限公司 Channel package generation method and device, storage medium and electronic device
CN109542415A (en) * 2018-11-13 2019-03-29 五八同城信息技术有限公司 The code merging method and relevant device for supporting application program to research and develop parallel
CN109542415B (en) * 2018-11-13 2022-05-10 五八同城信息技术有限公司 Code merging method supporting parallel research and development of application programs and related equipment
CN109522295B (en) * 2018-11-16 2021-07-20 中国银行股份有限公司 Automatic database object constructing and deploying method and device
CN109522295A (en) * 2018-11-16 2019-03-26 中国银行股份有限公司 A kind of database object constructs automatically, dispositions method and device
CN109857405A (en) * 2019-02-02 2019-06-07 Oppo广东移动通信有限公司 Compilation Method, device, storage medium and the terminal of application program installation kit
CN110201397A (en) * 2019-06-28 2019-09-06 北京金山安全软件有限公司 Game resource allocation method and device and electronic equipment
CN110201397B (en) * 2019-06-28 2022-07-22 北京金山安全软件有限公司 Game resource allocation method and device and electronic equipment
CN110457045A (en) * 2019-08-16 2019-11-15 百度在线网络技术(北京)有限公司 Modularization merges Compilation Method, device, equipment and storage medium
CN111090425A (en) * 2019-12-12 2020-05-01 支付宝(杭州)信息技术有限公司 Program packaging method and device and electronic equipment
CN110941443A (en) * 2019-12-12 2020-03-31 支付宝(杭州)信息技术有限公司 Method and device for modifying file name in SDK and electronic equipment
CN111381865A (en) * 2020-04-01 2020-07-07 深圳传趣网络技术有限公司 Packaging method, device and equipment of game application and storage medium
CN111611007A (en) * 2020-05-21 2020-09-01 掌阅科技股份有限公司 Script-based application program installation package packaging method and device
CN111611007B (en) * 2020-05-21 2023-08-29 掌阅科技股份有限公司 Method and equipment for packaging application program installation package based on script realization
CN111596931A (en) * 2020-05-27 2020-08-28 北京学之途网络科技有限公司 Application program packaging method and device, electronic equipment and readable storage medium
CN112052013A (en) * 2020-08-03 2020-12-08 完美世界(北京)软件科技发展有限公司 Software package generation method and device, storage medium and electronic device
CN112052013B (en) * 2020-08-03 2024-06-14 完美世界(北京)软件科技发展有限公司 Method and device for generating software package, storage medium and electronic device
CN112732644A (en) * 2020-12-31 2021-04-30 广州三七网络科技有限公司 Resource index processing method for application program, computer device and storage medium
CN112732644B (en) * 2020-12-31 2024-06-07 广州三七网络科技有限公司 Resource index processing method for application program, computer device and storage medium
CN112905170B (en) * 2021-03-09 2024-04-19 百果园技术(新加坡)有限公司 Channel package generation method, device, equipment and storage medium
CN112905170A (en) * 2021-03-09 2021-06-04 百果园技术(新加坡)有限公司 Channel package generation method, device, equipment and storage medium
CN113190263B (en) * 2021-04-21 2022-05-17 宝宝巴士股份有限公司 Method and device for integrating third-party SDK
CN113190263A (en) * 2021-04-21 2021-07-30 宝宝巴士股份有限公司 Method and device for integrating third-party SDK
CN113721929A (en) * 2021-08-11 2021-11-30 安徽帕觅智能科技有限公司 Method for automatically implanting common code into Android App

Similar Documents

Publication Publication Date Title
CN107844301A (en) A kind of Android application channel closes bag method and device
Holmes Hadoop in practice
Price C# 8.0 and. NET Core 3.0–Modern Cross-Platform Development: Build applications with C#,. NET Core, Entity Framework Core, ASP. NET Core, and ML. NET using Visual Studio Code
Nixon Learning PHP, MySQL & JavaScript
CN112256321A (en) Static library packaging method and device, computer equipment and storage medium
Karau Fastdata Processing with Spark
Samuel et al. Programming kotlin
Rossant Learning IPython for interactive computing and data visualization
Solorio et al. Hands-on smart contract development with Solidity and Ethereum: From fundamentals to deployment
Maksimović et al. Gillian, part II: real-world verification for javascript and C
Knight et al. Professional Microsoft SQL Server 2012 Integration Services
Price C# 9 and. NET 5–Modern Cross-Platform Development: Build intelligent apps, websites, and services with Blazor, ASP. NET Core, and Entity Framework Core using Visual Studio Code
Raj Neo4j high performance
Lano et al. Synthesis of mobile applications using AgileUML
Galowicz C++ 17 STL Cookbook
Roldán React Design Patterns and Best Practices: Design, build and deploy production-ready web applications using standard industry practices
Miller et al. Learning Python for Forensics: Leverage the power of Python in forensic investigations
Price C# 7.1 and. NET Core 2.0–Modern Cross-Platform Development: Create powerful applications with. NET Standard 2.0, ASP. NET Core 2.0, and Entity Framework Core 2.0, using Visual Studio 2017 or Visual Studio Code
Siddaway PowerShell and WMI
Marchioni MongoDB for Java developers
Azar et al. Swift data structure and algorithms
Sarka et al. SQL Server 2016 Developer's Guide
Salceanu Julia Programming Projects: Learn Julia 1. x by building apps for data analysis, visualization, machine learning, and the web
Hoffman Building Microservices with ASP. NET Core: Develop, Test, and Deploy Cross-platform Services in the Cloud
Kok Hands-On Blockchain for Python Developers: Gain blockchain programming skills to build decentralized applications using Python

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WW01 Invention patent application withdrawn after publication

Application publication date: 20180327

WW01 Invention patent application withdrawn after publication