MultiChannelPackageTool Documentation

repository·master·Indexed 21 days ago

https://github.com/seven456/multichannelpackagetool

A high-performance Android utility for injecting channel information or custom metadata into APK files by appending data to the Zip comment field. It avoids re-signing and decompression to ensure speed and compatibility. Includes a CLI via MCPTool.jar for writing and reading data, an MCPTool class for Android code integration, and Windows batch scripts for packaging and verification.

Tokens
969
Snippets
4
Records
6
Agent score
27%

What's inside MultiChannelPackageTool

  1. How MultiChannelPackageTool works

    master

    MultiChannelPackageTool is a high-speed Android multi-channel packaging tool. Unlike traditional tools that unzip, modify, and re-sign APKs, this tool leverages the Zip file structure's ability to add a "comment" (metadata) to the end of the file.

    By writing data directly to the end of the APK, it avoids the need for decompression, re-compression, or re-signing. This makes it extremely fast (e.g., processing a 5MB APK in a fraction of a second) and eliminates compatibility issues caused by re-signing. It also supports encrypting the written content for improved security.

  2. Use Windows batch scripts for quick packaging

    master

    For Windows users, the repository provides batch scripts for drag-and-drop usage:

    1. Packaging: Drag an APK onto MultiChannelPackageTool\build-ant\MCPTool\MCPTool.bat to perform multi-channel packaging.
    2. Verification: Drag an APK onto MultiChannelPackageTool\build-ant\MCPTool\MCPTool-check.bat to check if the channel ID was written successfully.

    Note: These batch files contain hardcoded passwords; you should modify them to match your requirements.

  3. Fix INSTALL_PARSE_FAILED_NO_CERTIFICATES error (Android 7.0 compatibility)

    master

    When using Android 7.0 or higher, you may encounter the error INSTALL_PARSE_FAILED_NO_CERTIFICATES because of the APK Signature Scheme v2. To ensure compatibility with this tool's method of appending data to the end of the file, you must force the use of the older signature scheme by disabling V2 signing in your build.gradle file.

    Requirement: This requires Gradle version $\ge$ 2.14.1 and Android Gradle Plugin version $\ge$ 2.2.0.

    signingConfigs {
        release {
            // ...
            v2SigningEnabled false // Disable V2 signature mode to maintain compatibility
        }
    }
  4. Read channel IDs in Android code using MCPTool class

    master

    To retrieve the channel ID or custom data within your Android application, import the MCPTool class from the MCPTool.jar library and use the getChannelId method.

    // Import MCPTool from the jar
    String channelId = MCPTool.getChannelId(context, mcptoolPassword, defValue);
  5. Reference: MCPTool CLI flags

    master

    The following flags are available for the MCPTool.jar command line interface:

    FlagDescription
    -pathPath to the APK file
    -outdirOutput directory (optional, defaults to the APK's directory)
    -contentsA collection of content to write, separated by ";" (e.g., googleplay;m360;). If omitted, the tool outputs existing content
    -passwordEncryption key (optional, must be 8+ characters). If omitted, data is not encrypted
    -versionDisplays the version number
    java -jar MCPTool.jar [-path] [arg] [-contents] [arg] [-password] [arg]
  6. Use the MCPTool CLI to package or read APKs

    master

    The tool is provided as a JAR file (MCPTool.jar) that can be executed via the command line. You can use it to write multiple channel IDs (or other data) into an APK or to read existing data from an APK.

    Writing data: Use the -contents flag to provide a semicolon-separated list of values. You can optionally use -password to encrypt the data.

    Reading data: Provide the -path to the APK and the -password used during writing to retrieve the content.

    # Writing multiple channels with encryption
    java -jar MCPTool.jar -path D:/test.apk -outdir ./ -contents googleplay;m360; -password 12345678
    
    # Reading the channels from an APK
    java -jar MCPTool.jar -path D:/test.apk -password 12345678