background

We’ve worked so hard to develop an App, and then someone just decompiles it and makes a copy of it. It’s really annoying. So we need to reinforce it with third-party services before releasing the App.

In addition, our apps are generally published in multiple App markets, and operators need to know how the data effect of each App market channel is, so we have to make multiple packages for our apps with App market channel information, which is convenient for operation statistical analysis

Common implementations

We can use some third-party multi-channel plug-ins to package, such as the famous Packer-ng-plugin, in addition, some third-party software also provides multi-channel packaging, such as 360 reinforcement Assistant. Below we introduce the specific use mode respectively

packer-ng-plugin

Packer-ng-plugin provides two ways, one is integrated into the project, the other is to download jar packages for script packaging

Multi-channel packaging through integration in a project

Just configure it according to the official website

//project build.gradle
dependencies {
    classpath 'com. McXiaoke. Packer - ng: plugin: 2.0.1'
}

//app model build.gradle
apply plugin: 'packer'

android {
    compileSdkVersion 25
    defaultConfig {
        ...
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }

        debug {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'}} packer {channelFile = new File(project.rootdir,"markets.txt"Github} dependencies {compile'com. McXiaoke. Packer - ng: helper: 2.0.1'
}
Copy the code

Then enter:

./gradlew clean apkRelease
Copy the code

It is also easy to get channel information in the application

String channel = PackerNg.getChannel(this);
Copy the code
Download the JAR package for script packaging

First you need to download the PackerNg JAR package, click here to download it

Then through the command line

Jar generate --channels=@ Channel file address ApK address of the output file pathCopy the code

Reinforce assistant with 360

360 reinforcement assistant provides reinforcement, signature, multi – channel package functions

Download address: 360 Reinforcement assistant

360 reinforcement assistant is relatively simple to use, configure the relevant information about the application

Through the above simple steps can strengthen the signature package of our App. And the signature already supports V2.

If we set up a multi-channel package, such as in the picture above, which is set to the UmENG statistics platform, the channel information in our application will be in the corresponding UMeng location in the AndroidManifest file. So how do we get channel information in the app? Here’s a way to get meta-data tags from AndroidManifest files.

// sysutils. class /** * Get the current channel number of the app or the meta-data specified in the application * to get the channel * for example, UMENG_CHANNEL ** @returnPublic static String getAppMetaData(Context Context, String key) {public static String getAppMetaData(Context Context, String key) {if (context == null || TextUtils.isEmpty(key)) {
        return null;
    }
    String channelNumber = null;
    try {
        PackageManager packageManager = context.getPackageManager();
        if(packageManager ! = null) { ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);if(applicationInfo ! = null) {if(applicationInfo.metaData ! = null) { channelNumber = applicationInfo.metaData.getString(key); } } } } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); }return channelNumber;
}
Copy the code

So we get channel information is very convenient

String channel = sysutils. getAppMetaData(this,"UMENG_CHANNEL");
Copy the code

conclusion

This article introduces how to package scripts and how to use third-party software packaging, which should be enough for daily development. There are a lot of third-party software which can reinforce the signature application, 360 is just one of them, we choose a handy good.


Did you improve today? Welcome to follow my wechat public number, and make progress with me every day!