Package on Eclipse and use the Proguard tool to confuse jar packages

Source: Internet
Author: User
Tags pack

Recently, due to the need for work, learned the packaging and confusion of the Android jar package.

Before thought is very easy, but their own in-depth study, found that there are some things need to pay attention to, and they also stepped on some pits, here to write for their colleagues for reference.
Reprint Please specify:

http://blog.csdn.net/aloh_a/article/details/50942751

How to pack

Here I packaged eclipse as a demo sample, assuming a friend was developed with Andorid Studio. I'm afraid I'm a little out.

    1. Select your project and right-click –>export

    2. Select Java Taxonomy –>jar file–> Next

    3. What we see here is the jar package generation option. What I need here is to generate a third-party SDK jar package for others to use, so I just need to generate the compiled class file in the SRC directory.

, usually the Res directory is not packaged, provided to the third party, will be corresponding to the RES resources to each other. and import them into each other's project.

If you have resources under the assets directory, you need to tick and pack. As for the Libs library, optional is also not optional. If you choose, the jar size will be larger, and I am not ticked here, since I will then consolidate all the jar packages into a single jar package. This will also facilitate third-party access, not so cumbersome to import multiple jar packages. Finally, select our jar generation path to do so.

4. Finally select a good option. We click Finish button. See for example with what you see. Then our jar package is built successfully.

Confuse

Before we get confused, we need to understand. Why do you confuse.

Here I participated in the next Guo Lin great God's blog, interested to know the next friend can see first.

Android security Attack War. Anti-compilation and obfuscation technology fully resolved
http://blog.csdn.net/guolin_blog/article/details/49738023
http://blog.csdn.net/guolin_blog/article/details/50451259

Guo Shen's Blog I briefly outlined below is. The jar packages and apk files that we generate are in fact not safe (detailed for non-encrypted latent Dragonfly FM events), with anti-compilation knowledge, including anti-compile code, and decompile resources. We were able to get the source code of the developer, even once again, to tamper with the developer's files for some purpose.

using the Proguard tool to confuse jar packages
Google is very human to provide us with a obfuscation tool, we can find it under the Sdk–>tools–>proguard–>bin–>proguardgui path, open for example.



Here is the Proguard obfuscation tool, which sees a load configuration button in the lower right corner, in fact its nature is still the configuration obfuscation option through the Proguard-android file, proguard-android File we were able to find it under Sdk–>tools–>proguard–>proguard-android.txt, by configuration. We can have our own confusing configuration file.

Next we click on the Input/output button in the left column. Go to the next step.
Here we see the above column, which is the configuration of the jar file to be confused and the file generation path after the confusion, we can configure it in the right column.
The following column is the other dependent jar package for the jar file that we want to confuse with project build.
The paths are all my native, and we see the last 2 jar packages more critical. The first one is your project development API's Android.jar package, path, second Java Rt.jar package, path dependent.

Here I have a pit. Because I installed 1.8 of the JDK myself. But I use my machine's Rt.jar package but confusion failed, will error such as the following: Proguard says unsupported class version number [52.0] (maximum 51.0, Java 1.7) with Sbt-p Roguard.

The reason is that Proguard only supports the JDK up to version 1.7, so I'm going to hang out here. After that, we found the jar package with the 1.7 version number and finally confused the success.


Next we click Next button to go to the next step, enter the shrinking option, remember to hook the shrink option off. Because we have this jar package that exists independently. No matter what the project reference, assuming that the shrink option in the hook will feel that all our code is useless, so that all the code is completely compressed. Export an empty jar package.

Continue to click Next to enter the obfuscation interface, where you can add some confusing logic. and confusing apk when it's different. This is not the way to help us eliminate the confusion of the four components, so you have to manually declare the line. And we can join in some of our own definitions without confusing classes or variables. As seen in 1. That is, I define the obfuscation rule, 2 is AddButton, click on it, will appear 3 interface, we can write the exclusion logic on it.

Suppose we want to confuse the activity class here. For example, see below. Finally, remember to press OK to save.

Is the result of my final confusion. Suppose we do not confuse the methods and variables of a class, that is, the 1 obfuscation rule, assuming that we do not confuse the methods and variables of all classes under a package, and refer to the 2 obfuscation rules.



Continue clicking next to enter the Optimiazation interface without changing anything, as we do not enable the optimization feature.

Continue to click Next to enter the information interface. There is no need to change anything, as we do not enable the Preverification feature.
Then click Next and go to the process interface, where you can preview our confusing configuration file by clicking on view Configurationbutton.

We can also save a copy of our own obfuscation profile by clicking on the Save Configuration button.
Last Click process! button can start to confuse.

Finally when we see success!

It means we are confused!

Suppose there is a warning hint. Then follow the instructions to make the corresponding changes. I hope this blog post will help you a little bit.

Package on Eclipse and use the Proguard tool to confuse jar packages

Related Article

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.