Android Studio Export jar package and confuse

Source: Internet
Author: User

In Android Studio, the self-contained anti-compilation view class file, if not confused, class files and Java files basically no difference, in order to protect, or confusing good.

Online read a lot of information, are directly download Proguard extra jar, directly generated, feel inconvenient, since the apk can be confused, why not directly through the Android studio to confuse the jar package it.

The procedure is actually very simple, a build file, a Proguard file can be.

The first thing to understand is where the jar came from, previously in Eclipse, a project was set up as a library, and then another master project relied on it. Build, the jar file will be generated in the library.

The concept of module in Android Studio is actually equivalent to project. The main app module relies on other sub-module, which, when packaged, will make the other module an AAR and assign it to the main app. So the jar is for the entire module to make.

If the module is just Java code, it is no problem to generate the jar, but if there is a resource file, you will have to hit the AAR file.

In the module build file where you want to hit the jar package, add a task that generates the jar package. In fact, even if not added, the entire project build will also generate the jar file. Can be found in Build/intermediates/bundles/release/classes.jar. It's just not confusing.

Task Makejar (Type:proguard.gradle.ProGuardTask, DependsOn: "Build") {
Non-confusing Jar
Injars ' Build/intermediates/bundles/release/classes.jar '
Confused Jar path
Outjars ' Build/http.jar '
Specific need to keep live class
Configuration ' Proguard-rules.pro '
}

This time, in the termial in the input./gradlew Makejar will be able to classes.jar copy down Http.jar. This time is still not confused, because the confusion is not written at all.

If the module also relies on other libs, it is necessary to declare those libs in the Proguard. For example: #-libraryjars Libs\gson-2.2.2.jar, most are confused with the apk similar, but is limited to a module only.

With a proguard for everyone to refer to, but also online search. The end result is not very good, but simply to change part of the variable to ABCD, but also enough. It's not always possible to confuse methods, so external calls are troublesome.

Proguard-rules.pro

Android Studio Export jar package and confuse

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.