Method of completing APK multi-channel packaging by Android secondary packaging
This paper introduces how to write the channel number into the assets file, extract APK, modify the files in assets, generate jarsigner script with java code and run the script for secondary packaging to obtain a new channel package
This packaging method only takes about 5 seconds for a channel package, which can realize fast channel package
The method to get the channel number from assets to print the channel package is actually very simple. You only need to know what is contained in APK
Decompress APK in a compressed way, and you will get the image
Such a list of files, including the assets folder; Of course, the prerequisite is that you must create an assets folder in the project. Now that you have this folder, Android can get the files in this folder through code and read the files:
Then, you only need to modify the files inside, repackage and sign to make the channel package.
How to modify the files inside and package signatures? I specially wrote a packaging tool to generate jars through Java projects, run jars through the command line, read the configuration files, and then generate packaging scripts. The scripts are automatically run for packaging
introduce
The entry in Java project is
Main function,
The operation of reading files is very simple. It is in the form of stream. Without much introduction, you can read the source code yourself
File configuration:
2. Unzip the APK file
3. Replace the channel number file
Get the unzipped assets path and modify the contents of the channel file,
4. Recompress to generate an. APK file, which is an unsigned file
5. Generate signature script content
6. Run the signature script
Interested students can look at the source code. When adding other channels, there is no need to configure gradle parameters. Just modify the configuration file and run the script
Today, I checked the jarsigner packaging command on the Internet and found that you can directly enter the password in the script, which can be packaged directly without repeatedly entering the password script:
jarsigner -verbose -keystore test.jks -storepass 123456 -keypass 123 456 -signedjar target\sing\youyi_ sin.apk target\unsing\youyi_ unsin.apk test
Source address: https://github.com/dengzhi00/ApkQuDao
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.