Gradle plugin for generating multiple channel apks
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
art
example
gradle/wrapper
src
.gitignore
LICENSE
README.md
build.gradle
gradlew
gradlew.bat

README.md

android-gradle-mulchannel-plugin

Gradle plugin for multiple channel apks

demo

Contents

Overview

This plugin generates multiple apks from different channel. Generation has to be invoked as additions gradle task.

Supported features

  • inputFile-config input file
  • tempDir-config unzip dir
  • outputDir-config output dir
  • channels-config multiple channels

Theory

If adding empty file in "META-INF" directory, do not need to sign the application.Therefore, by adding different empty file for the application of the different channels, can be the only one channel.

Testing

demo Rate = 10apk/20sec(300apk/10min)

Use plugin

In Remote(Not need clone thie project to use,require gradle 2.1)

1.Add plugin declare in build.gradle file

plugins {
  id "me.zhangls.mulchannel" version "0.2"
}

2.Config mulchannel extension(inputFile,tempDir,outputDir,channels),eg:

mulchannel {
    inputFile = file('lite-cmxj-debug.apk')
    tempDir = file('temp')
    outputDir = file('out')
    channels = ["qihu360","baidu","yingyongbao","wandoujia","taobao","xiaomi","nearme","anzhuo","anzhi","meizu"]
}

3.Use gradle mulchannel to make multiple channel apks

In Local(Need clone this project to use)

1.Use gradle install command,To install the plug in local maven

2.Add dependency to the top-level build.gradle file.

  buildscript {
    repositories {
      maven {
        url "https://plugins.gradle.org/m2/"
      }
    }
    dependencies {
      classpath "gradle.plugin.me.zhangls:android-gradle-mulchannel-plugin:0.2"
    }
  }

3.Apply plugin and add configuration to build.gradle of the application, eg:

apply plugin: 'me.zhangls.mulchannel'

4.Config mulchannel extension(inputFile,tempDir,outputDir,channels),eg:

mulchannel {
    inputFile = file('lite-cmxj-debug.apk')
    tempDir = file('temp')
    outputDir = file('out')
    channels = ["qihu360","baidu","yingyongbao","wandoujia","taobao","xiaomi","nearme","anzhuo","anzhi","meizu"]
}

5.Use gradle mulchannel to make multiple channel apks

Get channel

  public static String getChannel(Context context) {
    ApplicationInfo appinfo = context.getApplicationInfo();
    String sourceDir = appinfo.sourceDir;
    String ret = "";
    ZipFile zipfile = null;
    try {
        zipfile = new ZipFile(sourceDir);
        Enumeration<?> entries = zipfile.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = ((ZipEntry) entries.nextElement());
            String entryName = entry.getName();
            if (entryName.startsWith("META-INF/mulchannel")) {
                ret = entryName;
                break;
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (zipfile != null) {
            try {
                zipfile.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
  
    String[] split = ret.split("_");
    if (split != null && split.length >= 2) {
        return ret.substring(split[0].length() + 1);
  
    } else {
        return "";
    }
  }

Set channel

Will <meta-data android:value="Channel ID" android:name="UMENG_CHANNEL"/>
Channel ID replace the name of the marketing channels you apply
e.g. <meta-data android:value="Wandoujia" android:name="UMENG_CHANNEL"/>

If you don't want to in AndroidManifest.xml to config channel of umeng,you can also in Activity to config.
Please in launch activity to involved this method:AnalyticsConfig.setChannel(String channel)

Check signature

keytool -list -printcert -jarfile app.apk
The output will reveal the signature owner/issuer and MD5, SHA1 and SHA256 fingerprints.

License

MIT License See LICENSE file.