Learn more about Android to confuse your app code encrypt to prevent decompile

Source: Internet
Author: User

1. See if there are any proguard.cfg in the project.

2. If not, take a look at what is written in this file and copy it to your project after reading it.

-optimizationpasses 5

-Dontusemixedcaseclassnames

-dontskipnonpubliclibraryclasses

-dontpreverify

-verbose

-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*

-keep public class * extends Android.app.Activity

-keep public class * extends Android.app.Application

-keep public class * extends Android.app.Service

-keep public class * extends Android.content.BroadcastReceiver

-keep public class * extends Android.content.ContentProvider

-keep public class * extends Android.app.backup.BackupAgentHelper

-keep public class * extends Android.preference.Preference

-keep public class Com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {

native;

}

-keepclasseswithmembers class * {

Public (Android.content.Context, android.util.AttributeSet);

}

-keepclasseswithmembers class * {

Public (Android.content.Context, Android.util.AttributeSet, int);

}

-keepclassmembers enum * {

Public static **[] values ();

Public Static * * VALUEOF (java.lang.String);

}

-keep class * Implements Android.os.Parcelable {

Public static Final Android.os.parcelable$creator *;

}

3. After you copy to the project, open the Project.Properties file

4. Add a sentence in the project after opening: Proguard.config=proguard.cfg

5. This starts to sign your application according to the normal signature, the generated apk after the anti-compilation will be very different from the source code, but this step you will encounter a lot of problems, the signature is not successful. For example: ① If the project introduces the Android-support-v4 Jar class Library, then in the project packaging confusion, there will be error prompts you: "may need to specify additional library jars (using '- Libraryjars '). ② references to third party packages and other issues

6. Explain in detail the problems that occur in 5

If the project introduces the Android-support-v4 Jar class Library, then you will be in the back of proguard.cfg and add the following:

-libraryjars/android-support-v4.jar

-dontwarn android.support.v4.**

-keep class android.support.v4.** {*;}

-keep public class * extends android.support.v4.**

-keep public class * extends Android.app.Fragment

Then you pack it up and you should be able to build the APK installer properly.

If it appears: "Class 1 can ' t find referenced class 2" literally means that Class 1 cannot find a reference to class 2; it will suggest you: "The need to specify additional library jars (using '-libraryjars '). ";

The need to use-libraryjars plus third-party libraries used in the project is OK.

Example:-libraryjars/android-support-v4.jar

Note: The reference here is the current project's root directory (you can also configure other directories), that is, you want to put a third-party jar in the current directory, or you will be warned that the jar file cannot be found!

If it appears: can ' t find superclass or interface Android.os.parcelable$classloadercreator, in which case it is possible to use-dontwarn com.xx.yy . * *, no warning of errors.

Note: Use this method to ensure that you do not use the class in this library! Or they'll throw classnotfoundexception!.

If the class is actually used in the project, it is not possible to use the above method. Add another item at this time:-keep class com.xx.yy.** {*;}, so that the current class is not confused.

Summarize:

For cases where a third-party package is referenced, you can avoid packaging errors in the following ways:

-libraryjars/aaa.jar

-dontwarn com.xx.yy.**

-keep class com.xx.yy.** {*;}

Finally packaging success, I wish you a successful confusion encryption!

7. Attach the complete proguard.cfg

-optimizationpasses 5

-Dontusemixedcaseclassnames

-dontskipnonpubliclibraryclasses

-dontpreverify

-verbose

-optimizations!code/simplification/arithmetic,!field/*,!class/merging/*

-dontwarn com.slidingmenu.**

-keep class com.slidingmenu.** {*;}

-libraryjars /libs/android-support-v4.jar

-dontwarn android.support.v4.**

-keep class android.support.v4.** {*;}

-keep public class * extends android.support.v4.**

-keep public class * extends Android.app.Fragment

-keep public class * extends Android.app.Activity

-keep public class * extends Android.app.Application

-keep public class * extends Android.app.Service

-keep public class * extends Android.content.BroadcastReceiver

-keep public class * extends Android.content.ContentProvider

-keep public class * extends Android.app.backup.BackupAgentHelper

-keep public class * extends Android.preference.Preference

-keep public class Com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {

native;

}

-keepclasseswithmembers class * {

Public (Android.content.Context, android.util.AttributeSet);

}

-keepclasseswithmembers class * {

Public (Android.content.Context, Android.util.AttributeSet, int);

}

-keepclassmembers enum * {

Public static **[] values ();

Public Static * * VALUEOF (java.lang.String);

}

-keep class * Implements Android.os.Parcelable {

Public static Final Android.os.parcelable$creator *;

}

Transfer from http://blog.sina.com.cn/s/blog_6e334dc70101d5sh.html

Learn more about Android to confuse your app code encrypt to prevent decompile

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.