Android Art runtime with Dalvik virtual machine

Source: Internet
Author: User

These days when doing a project you need to use the OSGi framework (Apache Felix) in Android, and then experiment on a brand tablet on an Android 4.4.2 version of the system.

The experiment is simple: convert the Felix.jar package in the Felix bag and some bundles jar packs into the DX and AAPT tools in the Android SDK into a jar containing Dex bytecode. This allows the jar packs to run on Android. (Because Android is using a Dalvik virtual machine instead of a standard Java virtual machine, the "native" jar package does not run directly on Android) Then when I ran all the jar packages and copied them to the existing Android tablet, I reported the error:

Java.lang.unsupportedOperationException:can ' t load this type of class file.

At that time I thought it was a jar conversion error, and then deleted all the package, re-download re-conversion, and unexpectedly still reported such a mistake.

After a day of entanglement, it also occurred to me that it might be because of the art and Dalvik model issues. So copy the same jar package to your Android phone (the 4.4.4 version runs in Dalvik mode) and it runs smoothly. Then turn the phone into art mode and run the jar again and report the error on the tablet.

ART (Android Runtime)

Art is a more efficient and power-saving operating mechanism, and art mode is introduced in the Android 4.4 version, which can be set in the developer options-select Run mode. Now the latest version of Android L will set the art mode to default.

Dalvik virtual Machines

"Java Virtual machine" for running Java on Android. But it does not run a. class file (Java bytecode), but rather a. dex file (Dex bytecode). The Dalvik virtual machine contains an interpreter to execute the DEX byte code

It must be clear that two important different places

The Dalvik virtual machine explains that the Dex bytecode is executing.

The art virtual machine executes the local machine code. (These native machine codes are converted from Dex bytecode)

Consider the following conversion process:

Java–>java bytecode (. jar) –>dalvik bytecode (. Dex)

Java–>java bytecode (. jar) –>dalvik bytecode (. dex) –>optimized Android Runtime Machine code (. Odex)

The advantages of art

Art uses AOT (Ahead-of-time) compilation, and the bytecode is pre-compiled into machine code stored locally at the first installation. In Dalvik, the byte code needs to be converted to machine code and executed by the instant compiler every time the application is run.

While the app is running, the art mode is less likely to interpret bytecode than the Dalvik mode, so the app runs more efficiently and consumes less memory.

So Google in the latest version of the Android L the default art mode to start, is to hope that Android can get rid of the problem of lag. We also hope that the Android L can be silky smooth, saying that the personal feeling of the Android L paper-style design is really comfortable and cool.

Small price

The art mode is more efficient than the Dalvik mode and will pay a price, because to convert to machine code, the app occupies a corresponding increase in storage (details can be seen at the end of the test link), and the process of the conversion is in the app installation process, so the app installs the length of the corresponding increase of some , but these are trivial, because the app is only installed once, in order to run can be as smooth as silk, installation for a long time is also worthwhile.

Art runtime seamlessly replaces Dalvik virtual machines

While most of the current Android devices are running in Dalvik mode, how can art slowly replace Dalvik without affecting the use of the original Dalvik?

Here because the author is not to go to the development of Android this direction, so do not delve into the details inside, here strongly recommend the following blog, speak very detailed:

http://blog.csdn.net/luoshengyang/article/details/18006645 the Android Art runtime seamlessly replaces the Dalvik virtual machine process Analysis

Read Recommendation:

http://www.zhihu.com/topic/19905311 knows Android Runtime (ART)

Comparison between http://www.pcpop.com/doc/0/967/967006.shtml art and Dalvik test

NOTE: Reprint please indicate the source: http://www.programfish.com/blog/?p=113

Welcome to visit my personal website:http://www.programfish.com/

Android Art runtime with Dalvik virtual machine

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.