Speed channel packaging tool

  • V2.0.0-2017.06.23 – New release, supports V2 signature mode, includes several optimizations

Special note

SigningConfigs (v2SigningEnabled True) supports the APK Signature Scheme V2, which requires you to enable the APK Signature Scheme V2 in signingConfigs (v2SigningEnabled True). Look at v1.0.9 here.

Use guide

Maven Central

To modify the project root directorybuild.gradle

buildscript {
    dependencies{
        classpath 'Com. McXiaoke. Packer - ng: plugin: 2.0.0'}}Copy the code

Plug-in Configuration Example

packer {
    archiveNameFormat = '${buildType}-v${versionName}-${channel}'
    archiveOutput = new File(project.rootProject.buildDir, "apks")
//Douban channelList = [' * * ', 'Google/',' Chinese / @ # market 'and' Hello @ World,
//'GradleTest', '20070601! @ # $% ^ & * () {} : "< >? - = []; \ '. / ']
//    channelFile = new File(project.rootDir, "markets.txt")
    channelMap = [
            "Cat" : project.rootProject.file("channels/cat.txt"),
            "Dog" : project.rootProject.file("channels/dog.txt"),
            "Fish": project.rootProject.file("channels/channels.txt")]}Copy the code

  • archiveNameFormat– Specifies the format template for the final output channel package file name, described below. The default is${appPkg}-${channel}-${buildType}-v${versionName}-${versionCode}(optional)
  • archiveOutput– Specifies where the final output channel package is stored. The default is${project.buildDir}/archives(optional)
  • ChannelList – specifies the channelList. See the example
  • ChannelMap – Specifies different channel list files based on productFlavor, as shown in an example
  • ChannelFile – Specifies the channel list File. The File type is shown in the example

Note: The channelList, channelMap, and channelFile attributes cannot be used at the same time. Select one of them as required. If the three attributes exist at the same time, their priorities are as follows: ChannelList > channelMap > channelFile. In addition, these three attributes are overridden by the -pchannels command.

Integrated packaging

  • ProductFlavors is not used in the project

    ./gradlew clean apkRelease Copy the code

  • ProductFlavors is used in the project

    If multiple flavors are specified in the project, you need to specify the name of the flavor to be packaged. Assume that you have two Paid Free flavors, run the following command to package them:

    ./gradlew clean apkPaidRelease
    ./gradlew clean apkFreeReleaseCopy the code

    Using./gradlew clean apkRelease directly prints all flavor channel packages.

  • Specify the list of channels directly with an argument (which overrides properties in build.gradle) :

    ./gradlew clean apkRelease -Pchannels=ch1,ch2,douban,googleCopy the code

    This can be used when the number of channels is small.

  • Specify the location of the channel list file with an argument (which overrides properties in build.gradle) :

    ./gradlew clean apkRelease [email protected]Copy the code

    Use the @ symbol to specify the location of the channel list file, using a path relative to the project root.

  • You can also specify the output directory and file name format template:

    ./gradlew clean apkRelease -Poutput=build/apks 
    ./gradlew clean apkRelease -Pformat=${versionName}-${channel}Copy the code

    Channels Output format can be used in combination, and the command line argument overrides the build.gradle attribute.

  • Gradle packaging command description

    Apk ${flavor}${buildType} buildType = release, beta = someOtherType, beta = someOtherType Assume that the flavor is Paid, that the release type corresponds to apkPaidRelease, that the beta type corresponds to apkPaidBetaBeta, and so on.

  • Special note

    If you are using another compression tool or hardening feature, use the command line script to package the channel information. The channel information should be added at the end of the APK process.

[email protected] --output=build/archives app.apkCopy the code

  • Verification channel information:
packer-ng verify app.apkCopy the code

  • Run the command to view the help
Java jar tools/packer - ng - 2.0.0. Jar -- helpCopy the code

  • Python script reading channels:
python tools/packer-ng-v2.py app.apkCopy the code

  • C program reading channel:
cd tools
make
make install
packer app.apkCopy the code

Read channels in code

//If channel information is not found or an error is encountered, "" is returned by default.
// com.mcxiaoke.packer.helper.PackerNg
String channel = PackerNg.getChannel(Context)Copy the code

Other instructions

The channel reading C implementation is built using GenericMakefile. The APK Signing Block reads and writes Java implementations modified from Apksig and Walle. Thank you.


contact

The open source project

  • Rx 英 文 版 : github.com/mcxiaoke/Rx…
  • MQTT Protocol Chinese version: github.com/mcxiaoke/mq…
  • Awesome – Kotlin: github.com/mcxiaoke/aw…
  • Kotlin – Koi: github.com/mcxiaoke/ko…
  • Next Common Component library: github.com/mcxiaoke/An…
  • Gradle Channel package: github.com/mcxiaoke/gr…
  • EventBus xBus: github.com/mcxiaoke/xB…
  • Mushroom rice App: github.com/mcxiaoke/mi…
  • Fan No client: github.com/mcxiaoke/fa…
  • Volley Mirroring: github.com/mcxiaoke/an…