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