Ways to improve the security of APK files

Source: Internet
Author: User

First, the debugger detection

In reverse analysis of the APK, often take the dynamic debugging technology, can use netbeans+apktool to disassembly, generated Smali Code for dynamic Debugging. To prevent the APK from being dynamically debugged, you can detect if a debugger is connected.

ANDROID  ANDROID.OS.DEBUG  isdebuggerconnected () APPLICATION  isdebuggerconnected () method to determine if there is a debugger connection, if any, to exit the program directly.

In addition to the isdebuggerconnected method, you can also pass the application in the Androidmanifest file Adding android:debuggable= "false" to the node causes the program to not be debugged, so if you want to debug the code, you need to modify the value to true. So you can check the value of this property in your code to see if the program has been modified and the code is as follows:

Code :

  1. if (Getapplicationinfo (). Flags &= applicationinfo.flag_debuggable! = 0) {

  2. System.out.println ("Debug");

  3. Android.os.Process.killProcess (Android.os.Process.myPid ());

  4.}

Second, code confusion

code written in Java is easy to decompile, so you can use code obfuscation to add anti-compilation code

The difficulty of reading.Proguardis a freeJavaCode obfuscation tool that provides file compression, optimization, obfuscation, and auditing capabilities. In theEclipse+adtunder the development environment, eachAndroidthe Application project directory is generated by defaultproject.propertiesand theProguard-project.txtfile. If you need to useProguardTo compress and confuse, you first need toproject.propertiesuncomment the following statement in the file:

Code :

1. proguard.config=${sdk.dir}/tools/proguard/ Proguard-android.txt:proguard-project.txt

PROGUARD  PROGUARD-PROJECT.TXT  PROGUARD  ANDROIDMANIFEST  JNI  add -KEEP  command To hold the class or method.

It is also recommended that the apk Package Development can be done after a comprehensive vulnerability detection:http://www.ineice.com/, to ensure The security of the APK pack.

Ways to improve the security of APK files

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.