A detailed introduction to replacing jar package names with Jarjar.jar

Source: Internet
Author: User

Sometimes we need to replace the package name of the third party jar package according to some scenarios, such as the Android AD Platform SDK, replace their jar package name, can prevent the market to detect the advertising plug-in, so, today to introduce how to use the Jarjar.jar tool to replace the package name of the jar package

First, download the Jarjar.jar tool

Address in: https://code.google.com/p/jarjar/

Second, after downloading, use the cmd command--open to its directory, it has three commands:

(1)Java–jar jarjar.jar View Help information

(2)Java–jar Jarjar.jar strings <cp> This is to view all the package names inside the jar package.

For example, take the jar package for the multi-League AD as an example, using the following command:

Java-jar Jarjar.jar Strings Domob_android_sdk.jar

(3) The command to change the package name is:

Java-jar Jarjar.jar process <rulesFile> <inJar>  <outJar>

Note: There is an important thing in this is Rulesfile, which is to define a substitution rule. Injar is the jar package to be replaced, Outjar is replacing the jar package to be output

Rulesfile write directly with a. txt document,

Rulesfile has three directives, which are divided as follows:

1. Rule replaces the name of the package.

Rule pattern Result

2.zap is used to remove the package that matches the name.

Zap Pattern

3.keep only retains the name of the package that is compliant, and the others are erased. If used with ZAP, it will be executed after Zap executes.

Keep Pattern

Note: You can use "*" and "**" to represent any package name as a string of strings that is pattern. "*" can represent a layer of package,"**" that can represent a multi-tiered package.

Result is a string to be substituted for, you can use a notation such as "@1", "@2" to indicate the string to be represented by the "*" or "**" of the first few pattern.

If you want to replace all the "cn.domob" names in the jar package with "com.google", you can write the following rulesfile:

rule cn.domob.** [email protected]

Third, the formal replacement package name

Command for (all my jar packages are placed in the same directory, so you can use./):

java-jar Jarjar.jar process./rule.txt Domob_android_sdk.jar./google.jar

Already OK.

A detailed introduction to replacing jar package names with Jarjar.jar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.