1page.title=Platform Architecture 2page.keywords=platform,architecture,framework 3@jd:body 4 5 6<div id="qv-wrapper"> 7 <div id="qv"> 8 <h2> 9 In this document 10 </h2> 11 12 <ol> 13 <li> 14 <a href="#linux-kernel">The Linux Kernel</a> 15 </li> 16 17 <li> 18 <a href="#hal">Hardware Abstraction Layer (HAL)</a> 19 </li> 20 21 <li> 22 <a href="#art">Android Runtime</a> 23 </li> 24 25 <li> 26 <a href="#native-libs">Native C/C++ Libraries</a> 27 </li> 28 29 <li> 30 <a href="#api-framework">Java API Framework</a> 31 </li> 32 33 <li> 34 <a href="#system-apps">System Apps</a> 35 </li> 36 </ol> 37 </div> 38</div> 39 40<p> 41 Android is an open source, Linux-based software stack created for a wide 42 array of devices and form factors. The following diagram shows the major 43 components of the Android platform. 44</p> 45 46<img src="/guide/platform/images/android-stack_2x.png" alt="" width= 47"519"> 48<p class="img-caption"> 49 <strong>Figure 1.</strong> The Android software stack. 50</p> 51 52<h2 id="linux-kernel"> 53The Linux Kernel 54</h2> 55 56<p> 57 The foundation of the Android platform is the Linux kernel. For example, 58 <a href="#art">the Android Runtime (ART)</a> relies on the Linux kernel for 59 underlying functionalities such as threading and low-level memory management. 60</p> 61 62<p> 63 Using a Linux kernel allows Android to take advantage of <a href= 64 "https://source.android.com/security/overview/kernel-security.html">key 65 security features</a> and allows device manufacturers to develop hardware 66 drivers for a well-known kernel. 67</p> 68 69<h2 id="hal"> 70Hardware Abstraction Layer (HAL) 71</h2> 72 73<p> 74 The <a href= 75 "https://source.android.com/devices/index.html#Hardware%20Abstraction%20Layer"> 76 hardware abstraction layer (HAL)</a> provides standard interfaces that expose 77 device hardware capabilities to the higher-level <a href= 78 "#api-framework">Java API framework</a>. The HAL consists of multiple library 79 modules, each of which implements an interface for a specific type of hardware 80 component, such as the <a href= 81 "https://source.android.com/devices/camera/index.html">camera</a> or <a href= 82 "https://source.android.com/devices/bluetooth.html">bluetooth</a> module. 83 When a framework API makes a call to access device hardware, the Android 84 system loads the library module for that hardware component. 85</p> 86 87<h2 id="art"> 88Android Runtime 89</h2> 90 91<p> 92 For devices running Android version 5.0 (API level 21) or higher, each app 93 runs in its own process and with its own instance of the <a href= 94 "http://source.android.com/devices/tech/dalvik/index.html">Android Runtime 95 (ART)</a>. ART is written to run multiple virtual machines on low-memory 96 devices by executing DEX files, a bytecode format designed specially for 97 Android that's optimized for minimal memory footprint. Build toolchains, such 98 as <a href="https://source.android.com/source/jack.html">Jack</a>, compile 99 Java sources into DEX bytecode, which can run on the Android platform. 100</p> 101 102<p> 103 Some of the major features of ART include the following: 104</p> 105 106<ul> 107 <li>Ahead-of-time (AOT) and just-in-time (JIT) compilation 108 </li> 109 110 <li>Optimized garbage collection (GC) 111 </li> 112 113 <li>Better debugging support, including a dedicated sampling profiler, 114 detailed diagnostic exceptions and crash reporting, and the ability to set 115 watchpoints to monitor specific fields 116 </li> 117</ul> 118 119<p> 120 Prior to Android version 5.0 (API level 21), Dalvik was the Android runtime. 121 If your app runs well on ART, then it should work on Dalvik as well, but 122 <a href="/guide/platform/verifying-apps-art.html">the reverse may not be 123 true</a>. 124</p> 125 126<p> 127 Android also includes a set of core runtime libraries that provide most of 128 the functionality of the Java programming language, including some <a href= 129 "/guide/platform/j8-jack.html">Java 8 language features</a>, that the Java 130 API framework uses. 131</p> 132 133<h2 id="native-libs"> 134 Native C/C++ Libraries 135</h2> 136 137<p> 138 Many core Android system components and services, such as ART and HAL, are 139 built from native code that require native libraries written in C and C++. 140 The Android platform provides Java framework APIs to expose the functionality 141 of some of these native libraries to apps. For example, you can access 142 <a href="/guide/topics/graphics/opengl.html">OpenGL ES</a> through the 143 Android framework’s <a href= 144 "/reference/android/opengl/package-summary.html">Java OpenGL API</a> to add 145 support for drawing and manipulating 2D and 3D graphics in your app. 146</p> 147 148<p> 149 If you are developing an app that requires C or C++ code, you can use the 150 <a href="/ndk/index.html">Android NDK</a> to access some of these <a href= 151 "/ndk/guides/stable_apis.html">native platform libraries</a> directly from 152 your native code. 153</p> 154 155<h2 id="api-framework"> 156Java API Framework 157</h2> 158 159<p> 160 The entire feature-set of the Android OS is available to you through APIs 161 written in the Java language. These APIs form the building blocks you need to 162 create Android apps by simplifying the reuse of core, modular system 163 components and services, which include the following: 164</p> 165 166<ul> 167 <li>A rich and extensible <a href="/guide/topics/ui/overview.html">View 168 System</a> you can use to build an app’s UI, including lists, grids, text 169 boxes, buttons, and even an embeddable web browser 170 </li> 171 172 <li>A <a href="/guide/topics/resources/overview.html">Resource Manager</a>, 173 providing access to non-code resources such as localized strings, graphics, 174 and layout files 175 </li> 176 177 <li>A <a href="/guide/topics/ui/notifiers/notifications.html">Notification 178 Manager</a> that enables all apps to display custom alerts in the status bar 179 </li> 180 181 <li>An <a href="/guide/components/activities.html">Activity Manager</a> that 182 manages the lifecycle of apps and provides a common <a href= 183 "/guide/components/tasks-and-back-stack.html">navigation back stack</a> 184 </li> 185 186 <li> 187 <a href="/guide/topics/providers/content-providers.html">Content 188 Providers</a> that enable apps to access data from other apps, such as 189 the Contacts app, or to share their own data 190 </li> 191</ul> 192 193<p> 194 Developers have full access to the same <a href= 195 "/reference/packages.html">framework APIs</a> that Android system apps use. 196</p> 197 198<h2 id="system-apps"> 199System Apps 200</h2> 201 202<p> 203 Android comes with a set of core apps for email, SMS messaging, calendars, 204 internet browsing, contacts, and more. Apps included with the platform have 205 no special status among the apps the user chooses to install. So a 206 third-party app can become the user's default web browser, SMS messenger, or 207 even the default keyboard (some exceptions apply, such as the system's 208 Settings app). 209</p> 210 211<p> 212 The system apps function both as apps for users and to provide key 213 capabilities that developers can access from their own app. For example, if 214 your app would like to deliver an SMS message, you don't need to build that 215 functionality yourself—you can instead invoke whichever SMS app is already 216 installed to deliver a message to the recipient you specify. 217</p>