Android obfuscation (obfuscate)

Source: Internet
Author: User

The author of the article "obfuscate an Android Application" describes how to confuse programs on the Android platform and give ant build. XML file. After testing, we found that some target items were missing, and errors occurred in ipvs. Later, we combined the zxing open-source project build. the XML file is finally obfuscated successfully, and the project package is reduced a lot.

 

Here are some important notes that do not provide source code.

1. Create the build. xml file

Create a file named build. XML in the project directory.

 

 

2. Create an ant package

Project-> properties-> builders-> New-> ant Builder

 

 

Next, select the Project Build. xml file for buildfile, and select the project directory for base dir. Remember to check your builders.

 

 

 

3. Modify the build. xml file

The zxing file does not include the confusion package option, so you have to make some modifications, as shown in the following example:

 

XML Code
  1. <Property name = "proguard-home" value = "D: // program files // proguard4.2 // lib //"/>
  2. <Target name = "optimize" depends = "compile">
  3. <Jar basedir = "$ {outdir-classes}" destfile = "Temp. Jar"/>
  4. <Java jar = "$ {proguard-home}/proguard. Jar" fork = "true" failonerror = "true">
  5. <Jvmarg value = "-dmaximum. inlined. Code. Length = 32"/>
  6. <Arg value = "-injars temp. Jar"/>
  7. <Arg value = "-outjars optimized. Jar"/>
  8. <Arg value = "-libraryjars $ {Android-jar}"/>
  9. <! -- <Arg value = "-libraryjars $ {library-jar}/some_lib_used.jar"/> -->
  10. <Arg value = "-dontpreverify"/>
  11. <Arg value = "-dontoptimize"/>
  12. <Arg value = "-dontusemixedcaseclassnames"/>
  13. <Arg value = "-repackageclasses'' "/>
  14. <Arg value = "-allowaccessmodification"/>
  15. <Arg value = "-keep public class com. iwidsets. widsetsactivity"/>
  16. <! -- <Arg value = "-keep public class com. just2me. obfapp. Er er. *"/> -->
  17. <Arg value = "-optimizationpasses 7"/>
  18. <Arg value = "-verbose"/>
  19. <Arg value = "-dontskipnonpubliclibraryclasses"/>
  20. <Arg value = "-dontskipnonpubliclibraryclassmembers"/>
  21. </Java>
  22. <Delete file = "Temp. Jar"/>
  23. <Delete dir = "$ {outdir-classes}"/>
  24. <Mkdir dir = "$ {outdir-classes}"/>
  25. <Unzip src = "optimized. Jar" DEST = "$ {outdir-classes}"/>
  26. <Delete file = "optimized. Jar"/>
  27. </Target>

 

Note: change keep public class com. iwidsets. widsetsactivity to your main activity.

 

And modify target Dex.

 

XML Code
  1. <! -- Convert this project's. class files into. Dex files. -->
  2. <Target name = "Dex" depends = "compile, optimize">
  3. <Echo> converting compiled files and external libraries into $ {out-Folder}/$ {Dex-file}... </echo>
  4. <Apply executable = "$ {DX}" failonerror = "true" parallel = "true">
  5. <Arg value = "-- Dex"/>
  6. <Arg value = "-- output =$ {Intermediate-Dex-location}"/>
  7. <Arg Path = "$ {outdir-classes-location}"/>
  8. <Fileset dir = "$ {external-libs-Folder}" includes = "*. Jar"/>
  9. </Apply>
  10. </Target>

 

  • View image attachments
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.