android--Compile Odex protection

Source: Internet
Author: User

Compiled Android source code may have tried to modify the compilation type, Android initialization compiled configuration can refer to http://blog.csdn.net/jscese/article/details/23931159


I. Target_build_variant=user

When the selected compilation type is user , you can see it in/build/core/main.mk (Android 4.2):

  # Turn on Dalvik preoptimization for user builds, but only if not  # explicitly disabled and the ' build is ' running on Li Nux (since host  # Dalvik isn ' t built for Non-linux hosts).  Ifneq (true,$ (disable_dexpreopt))    ifeq ($ (user_variant), user)      ifeq ($ (host_os), Linux)        with_dexpreopt: = True      endif    endif  endif

From the logic above, you can see that. disable_dexpreoptSettings and:

User_variant: = $ (Filter user userdebug,$ (target_build_variant))

and Host_os These three variables determine with_dexpreopt


When compiling, traversing the module that needs to be compiled, in/build/core/package.mk, as to why the makefile is bought because the ANDROID.MK in module include $ (build_ Package), this is the Android build system.

Ifneq (true,$ (with_dexpreopt)) Local_dex_preopt: =elseifeq (, $ (Target_build_apps)) Ifneq (, $ (local_src_files)) ifndef Local_dex_preoptlocal_dex_preopt: = Trueendifendifendifendififeq (false,$ (local_dex_preopt)) LOCAL_DEX_PREOPT: = endif

This part of the logic from Package.mk can be seen, Target_build_appsThe empty is set in the lunch command in the previous article, which represents full compilation! And Local_src_filesCan not be empty, meaning that there is a source of

If not defined at this time, then the variable local_dex_preopt = True.


Then look down:

Ifdef local_dex_preopt# Make sure the boot jars get dexpreopt-ed first$ (local_built_module): $ (Dexpreopt_boot_odexs) | $ (dexpreopt) $ (dexopt) endif

Ifdef local_dex_preopt$ (Hide) rm-f $ (patsubst%.apk,%.odex,[email protected]) $ (call Dexpreopt-one-file,[email protected],$ (Patsubst%.apk,%.odex,[email protected]) Ifneq (nostripping,$ (local_dex_preopt)) $ (call Dexpreopt-remove-classes.dex,[email protected]) endif

Both of these logical executions are in/BUILD/CORE/DEX_PREOPT.MK.

Dexpreopt_boot_odexs: = $ (foreach b,$ (dexpreopt_boot_jars_modules),    $ (Dexpreopt_boot_jar_dir_full_path)/$ (b). Odex


Generate the. odex! for those jar packages.



The tool is defined in/BUILD/CORE/CONFIG.MK:

Dexopt: = $ (host_out_executables)/dexopt$ (host_executable_suffix) dexpreopt: = dalvik/tools/dex-preopt


In the process of generating apk and jar:

# $ (1): the input. jar or. APK file# $ (2): the output. Odex filedefine dexpreopt-one-file$ (hide) $ (dexpreopt)--dexopt=$ (D expreopt_dexopt)--build-dir=$ (dexpreopt_build_dir)--product-dir=$ (dexpreopt_product_dir)--boot-dir=$ (DEXPREOPT _boot_jar_dir)--boot-jars=$ (dexpreopt_boot_jars) $ (dexpreopt_uniprocessor) $ (Patsubst $ (DEXPREOPT_BUILD_DIR)/%,%, $ (1)) $ (Patsubst $ (Dexpreopt_build_dir)/%,%,$ (2)) Endef


Again by:

# $ (1): the. jar or. apk to remove Classes.dexdefine dexpreopt-remove-classes.dex$ (hide) $ (AAPT) Remove $ (1) Classes.dexen Def

To remove. Dex

General compilation configuration and process introduced here, the details are in such a few files, not much to write!



Two.. Odex effect

It says that the build *.odex, each corresponding jar and apk can generate a corresponding. Odex, and remove. Dex, so that the individual jar and apk are incomplete and cannot be used by the Android system properly! Use only with. Odex.

System production will put. Odex and apk together under the System/app, by the system to dispatch the use, if you want to pirate apk, Copy it out. APK is not available, and you must decompile the corresponding. Odex for. Dex, repackaging the APK package before you can use it and decompile it. Odex also need to use this apk has the relevant jar package!

And our system produced Framework.jar also has Framework.odex! This can play a protective role to a certain extent! As for the online various anti-compilation Odex and then signature methods have a lot, not much to do introduction.





Writing is not easy, reproduced please specify the source: http://blog.csdn.net/jscese/article/details/32702321






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.