mkstubs

make stub jar package from complete jar

License

License

GroupId

GroupId

com.lxzh123
ArtifactId

ArtifactId

mkstubs
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

mkstubs
make stub jar package from complete jar
Project URL

Project URL

https://github.com/lxzh/SecShell
Source Code Management

Source Code Management

https://github.com/lxzh/SecShell

Download mkstubs

How to add to project

<!-- https://jarcasting.com/artifacts/com.lxzh123/mkstubs/ -->
<dependency>
    <groupId>com.lxzh123</groupId>
    <artifactId>mkstubs</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.lxzh123/mkstubs/
implementation 'com.lxzh123:mkstubs:1.0.1'
// https://jarcasting.com/artifacts/com.lxzh123/mkstubs/
implementation ("com.lxzh123:mkstubs:1.0.1")
'com.lxzh123:mkstubs:jar:1.0.1'
<dependency org="com.lxzh123" name="mkstubs" rev="1.0.1">
  <artifact name="mkstubs" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.lxzh123', module='mkstubs', version='1.0.1')
)
libraryDependencies += "com.lxzh123" % "mkstubs" % "1.0.1"
[com.lxzh123/mkstubs "1.0.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

SecShell

中文说明

1. prepare shell tool

Only need to compile once, subsequent libshell remains unchanged, just replace the sdk.data in assets

gradle libshell:build

build libshell and copy libshell.aar to the sdk directory

2. prepare sdk

  • build sdk

build the sdk to be reinforced, such as libcore

gradle libcore:build

After compiling, copy the aar to the sdk directory and modify the 'SDK_AAR_NAME' in gradle.properties to configure the file name of the corresponding aar

3. sdk proguard

  • generate stub-sdk

To hide the key code of our sdk and ensure that users can develop properly, we provide stub-sdk for user compileOnly reference, and load the actual SDK through shell tools. In this scheme, the stub-sdk is generated based on the reflection principle of Java. Empty Java classes are generated by loading the jar file in the aar package of SDK.

gradle libmix:build

Compiling libmix performs the following tasks in sequence:

  1. Unzip the aar file of sdk to the sdk/sdk directory, extract the classes.jar package from the sdk directory and rename it as sdk.jar
  2. Extract libshell aar file to sdk/shell directory
  3. Convert sdk.jar to sdk.dex file for encryption
  4. Generate a stub jar based on sdk.jar for the user app to reference through compileOnly. In this example, the compilation script will automatically copy the jar to the demo dependent library directory, the specific path is specified by DEMO_LIB_FOLDER in gradle.properties
  5. Encrypt dex and copy it to sdk/shell/assets/. Then repackage libshell as aar file and automatically copy aar to the specified demo dependent library directory, the path is specified by DEMO_LIB_FOLDER in gradle.properties

4. build demo

gradle demo:build

build the demo project to get example apk

If you want to be compatible with android4.1~android4.4, all classes referenced to corestub in Application must add a wrapper to pass through methods in those classes. Such as:

Application中引用LIB:

import com.lxzh123.corestub.LIB;
...
int square = LIB.get().square(5);
Log.d(TAG, "call lib.square:" + square);

Add a wrapper class to ensure that LIB is not exposed to Application:

package com.lxzh123.sdkshellapp;

import com.lxzh123.libcore.LIB;

/**
 * Compatible with android4.x version
 */
public class CoreStub {
    public static int init(int param) {
        return LIB.get().square(param);
    }
}

Reference LIB indirectly by referencing the wrapper class:

int square = CoreStub.init(5);
Log.d(TAG, "call lib.square:" + square);

Versions

Version
1.0.1
1.0.0