Android L Development Guide

Source: Internet
Author: User

Introductory Remarks: What does the Android next generation operating system "L" mean to developers? Can art mode make an app experience beyond Apple?

At the end of the Google I/O Conference, the Android next-generation operating system "L" brought a lot of surprises. The new system runs faster and more power-saving.

However, developers have a lot of questions about the new system, such as what does the new running mode art mean for developers? Can art mode make an app experience beyond Apple? 360 first-seat technical expert Zhing that the performance of "L" in the art mode of operation increased from 15% to 80%. At the same time, art optimizes garbage collection by 50% more than the current Dalvik, reducing the lag in the application when performing garbage collection and making the application run smoother.

Android L Run interface

In terms of security, there is no change in the security model and the underlying mechanism compared to art and Dalvik. But art has some details to improve and is safe to help. For example, the Dex file is more rigorously validated during installation.

The following compilation of 360 forums on the developer asked the most 6 questions, 360 technical Experts Zhing did the answer, hoping to help developers to better understand the new system.

question 1. Why Art can improve performance?

Answer: mainly from two aspects.

One, pre (ahead-of-time) compile. When Android apps are developed, the generated Dex file contains the Java byte Code. Before Android L, the Dalvik virtual machine was used by default. When the app runs, Dalvik interprets Java Byte code, or compiles junt-in-time. In Android L, when the app is installed, use the System Tools dex2oat to compile the Dex files in the installation package into an elf-formatted executable file (. oat file). The application runtime executes the binary instructions directly.

Second, optimize garbage collection (garbage collection). There are two main types of garbage collection: (1) gc_concurrent. At execution time, Dalvik will pause the execution of the code for a short time at the beginning and end of the GC. (2) Gc_for_alloc. When executed, it interrupts the operation of the Java code for a long time. In art, when you execute gc_concurrent, only the code is paused once. When executing Gc_for_alloc, the time to break the Java code is greatly reduced. In general, art garbage collection consumes more than 50% less overhead than Dalvik. Reduces the lag in the application when garbage collection occurs, making the application run more smoothly.

question 2. what needs to be done for application developers to support art . Like recompiling, packing?

A: For the vast majority of developers, there is no need. Whether the virtual machine is Dalvik or art, the installation package still contains the Dex file. The work of compiling a binary file from the Dex file is done by the System tool dex2oat on the device when the application is installed.

question 3. will developers be able to debug on the Java level after Android apps are running in art ?

Answer: Yes. In fact, after the app is installed, the generated. Oat file is compiled with the original Dex file. There are two reasons to keep the Dex file: first, you need information about the class in Dex to support operations such as Java reflection. Second, debugging, you need to use the debug information in Dex. For this reason, compiling the generated. Oat file is twice times larger than the original Dex file.

question 4. with Art , how much performance can ultimately be improved?

Answer: Depending on the application. On Google I/O, Google gives an example of an increase of more than twice times.

Art we actually tested it and improved performance from 15% to 80%. For applications that use a large number of CPUs, performance gains are noticeable. But if the application's time is mostly spent calling the system API, the promotion will be smaller. Because many of the system API's code is mainly in the underlying. So.

question 5. Has ART improved in safety?

A: The security model and basic mechanism have not changed compared to art and Dalvik. But art has some details to improve and is safe to help. For example: First, the Dex files are more rigorously verified during installation. Second, corrects the problem of an object model that Dalvik a long-term existence: A method in a class, if there are no restrictions on access (that is, not described with public,private,protected), the Java rule is the Package-private method, Subclasses that are not in the same package cannot be accessed and overloaded. Dalvik, however, has allowed subclasses to overload package-private methods. Art has been modified to act in accordance with Java standards.

question 6. What do I have to pay attention to when I use art in Android?

A: One, because the installation was pre-compiled. The application installation takes longer and the files generated after installation become larger.

Second, if the code is loaded in the form of Dexclassloader, the first execution time will also become longer.

Third, the best compatibility test for the application. Most applications do not need to be modified, but if the application itself handles Dex files, such as packers, there may be compatibility issues.

Overall, Android L is well worth the wait, Google will launch the official version this fall, but in view of the current fragmentation of the Android system, most of the current mobile phones can not be upgraded, can only buy new phones.

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.