Configure the Android emulator Dex file not to be optimized into Odex

Source: Internet
Author: User
Tags command line

Recently done a module, you need to load the APK inside the Dex file dump out, so need to configure to Dalvik not to the Dex file optimization into Odex.

1. Configure Build.prop

Mainly by modifying the configuration of the file/system/build.prop inside.

(1) Dalvik.vm.dexopt-flags

This parameter controls the program code calibration and optimization of the Dalvik virtual machine. The values that can be filled in are M, V, and O.
M is a standard option and can be m=y or m=n. If m=y enables the validation of unsafe code and the optimization of managed code. Highest compatibility and security.
V for CHECK option, can coexist with O. can be v=a or v=n. If v=a verifies all the code, v=n turns off the validation of the code.
o for optimization options, can coexist with V. can be o=v or o=a. If O=v represents optimized code that is validated, o=a indicates that all code is optimized.

Here we configure: Dalvik.vm.dexopt-flags=v=n,o=v to turn off the code checksum and only optimize the validated code, that is, all code will not be optimized.

(2) Dalvik.vm.checkjni

Here we configure: Dalvik.vm.checkjni=false, this will set the Checkjni to False

2. Persisting the configuration to the simulator

(1) Mount the system partition first to make the system partition writable. If you do not do this, you will find that you cannot modify the Build.prop file.

ADB remount

(2) Next, enter the command line of the simulator:

ADB shell

(3) Write configuration to Build.prop:

echo "Dalvik.vm.dexopt-flags=v=n,o=v" >>/system/build.propecho "Dalvik.vm.checkjni=false" >>/system/ Build.prop

In this way, the preparation was changed to the simulator, after verification found that Dex has not been converted into Odex.

But after restarting the simulator, I found that the changes in Build.prop were gone.

Search the Internet for a while, referring to the StackOverflow question: http://stackoverflow.com/questions/15417105/ Forcing-the-android-emulator-to-store-changes-to-system

The specific steps are as follows:

(1) Copy the system.img to a place,

(2) Start the simulator with the following command:

EMULATOR-AVD [your emulator name]-qemu-nand system,size=[Simulator required space, 16],file=[just copied directory]/system.img
For example:
emulator-avd galaxy_nexus-qemu-nand system,size=0x1f400000,file=/home/fx/.android/avd/galaxy_nexus/ System.img

(3) Modify the Build.prop according to the previous steps

(4) Turn off the simulator with this command:

ADB-E EMU Kill

This way, the next time you start the simulator normally (no more than the command in step 2 above), you find that the modified content has been persisted into the build.prop.

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.