สถาปัตยกรรมแพลตฟอร์ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Android เป็นสแต็กซอฟต์แวร์โอเพนซอร์สที่ใช้ Linux ซึ่งสร้างขึ้นสำหรับอุปกรณ์และรูปแบบของอุปกรณ์ที่หลากหลาย
รูปที่ 1 แสดงองค์ประกอบหลักของแพลตฟอร์ม Android
รูปที่ 1 สแต็กซอฟต์แวร์ Android
เคอร์เนล Linux
รากฐานของแพลตฟอร์ม Android คือเคอร์เนล Linux ตัวอย่างเช่น Android Runtime (ART) อาศัยเคอร์เนล Linux สำหรับ
ฟังก์ชันการทำงานพื้นฐาน เช่น การจัดการหน่วยความจำแบบหลายเธรดและระดับต่ำ
การใช้เคอร์เนล Linux ช่วยให้ Android ใช้ประโยชน์จากฟีเจอร์
ด้านความปลอดภัยที่สำคัญ และช่วยให้ผู้ผลิตอุปกรณ์พัฒนาไดรเวอร์ฮาร์ดแวร์
สำหรับเคอร์เนลที่รู้จักกันดีได้
ระดับชั้นการจัดการฮาร์ดแวร์โดยตรง (HAL)
Hardware Abstraction Layer (HAL) มีอินเทอร์เฟซมาตรฐานที่แสดง
ความสามารถของฮาร์ดแวร์ของอุปกรณ์ต่อเฟรมเวิร์ก Java API ระดับที่สูงกว่า HAL ประกอบด้วยโมดูลไลบรารีหลายโมดูล
ซึ่งแต่ละโมดูลจะใช้การติดตั้งใช้งานอินเทอร์เฟซสำหรับคอมโพเนนต์ฮาร์ดแวร์ประเภทหนึ่งๆ
เช่น โมดูลกล้องหรือบลูทูธ
เมื่อ API ของเฟรมเวิร์กเรียกใช้เพื่อเข้าถึงฮาร์ดแวร์ของอุปกรณ์ ระบบ Android
จะโหลดโมดูลไลบรารีสำหรับคอมโพเนนต์ฮาร์ดแวร์นั้น
รันไทม์ของ Android
สำหรับอุปกรณ์ที่ใช้ Android เวอร์ชัน 5.0 (API ระดับ 21) ขึ้นไป แอปแต่ละแอปจะทำงานในกระบวนการของตัวเองและมีอินสแตนซ์ของ Android Runtime (ART) เป็นของตัวเอง ART เขียนขึ้นเพื่อเรียกใช้เครื่องเสมือนหลายเครื่องในอุปกรณ์ที่มีหน่วยความจำน้อย
โดยการเรียกใช้ไฟล์รูปแบบ Dalvik Executable (DEX) ซึ่งเป็นรูปแบบไบต์โค้ดที่ออกแบบมาโดยเฉพาะสำหรับ
Android และได้รับการเพิ่มประสิทธิภาพให้ใช้หน่วยความจำน้อยที่สุด เครื่องมือบิลด์ เช่น d8
จะคอมไพล์แหล่งที่มาของ Java เป็นไบต์โค้ด DEX ซึ่งทำงานบนแพลตฟอร์ม Android ได้
ฟีเจอร์หลักบางส่วนของ ART มีดังนี้
- การคอมไพล์ล่วงหน้า (AOT) และการคอมไพล์ JIT (Just-In-Time)
- การจัดการหน่วยความจำที่ไม่ใช้แล้ว (GC) ที่เพิ่มประสิทธิภาพ
- ใน Android 9 (API ระดับ 28) ขึ้นไป
การแปลงไฟล์ DEX ของ
แพ็กเกจแอปเป็นโค้ดแมชชีนที่กะทัดรัดมากขึ้น
- การรองรับการแก้ไขข้อบกพร่องที่ดียิ่งขึ้น ซึ่งรวมถึงเครื่องมือสร้างโปรไฟล์การสุ่มเฉพาะ
ข้อยกเว้นในการวินิจฉัยโดยละเอียดและการรายงานข้อขัดข้อง รวมถึงความสามารถในการตั้งค่า
จุดสังเกตเพื่อตรวจสอบฟิลด์ที่เฉพาะเจาะจง
ก่อน Android เวอร์ชัน 5.0 (API ระดับ 21) Dalvik เป็นรันไทม์ของ Android
หากแอปทำงานได้ดีใน ART ก็จะทำงานใน Dalvik ได้เช่นกัน แต่ในทางกลับกันอาจไม่เป็นเช่นนั้น
นอกจากนี้ Android ยังมีชุดไลบรารีรันไทม์หลักที่ให้ฟังก์ชันการทำงานส่วนใหญ่ของภาษาการเขียนโปรแกรม Java ซึ่งรวมถึงฟีเจอร์ภาษา Java 8 บางอย่างที่เฟรมเวิร์ก Java API ใช้
ไลบรารี C/C++ แบบเนทีฟ
คอมโพเนนต์และบริการหลักของระบบ Android หลายอย่าง เช่น ART และ HAL สร้างขึ้นจากโค้ดแบบเนทีฟที่ต้องใช้ไลบรารีแบบเนทีฟที่เขียนด้วย C และ C++ แพลตฟอร์ม Android มี API ของเฟรมเวิร์ก Java เพื่อแสดงฟังก์ชันการทำงานของไลบรารีแบบเนทีฟบางส่วนเหล่านี้ต่อแอป เช่น คุณสามารถเข้าถึง OpenGL ES ผ่าน Java OpenGL API ของเฟรมเวิร์ก Android เพื่อเพิ่มการรองรับการวาดและจัดการกราฟิก 2 มิติและ 3 มิติในแอป
หากคุณกำลังพัฒนาแอปที่ต้องใช้โค้ด C หรือ C++ คุณสามารถใช้ Android NDK เพื่อเข้าถึงไลบรารีแพลตฟอร์มแบบเนทีฟบางส่วนเหล่านี้ได้โดยตรงจากโค้ดแบบเนทีฟ
เฟรมเวิร์ก Java API
คุณสามารถใช้ชุดฟีเจอร์ทั้งหมดของระบบปฏิบัติการ Android ผ่าน API ที่เขียนด้วยภาษา Java
API เหล่านี้เป็นส่วนประกอบพื้นฐานที่คุณต้องใช้ในการ
สร้างแอป Android โดยการลดความซับซ้อนของการนำส่วนประกอบและบริการหลักของระบบแบบโมดูลกลับมาใช้ใหม่ ซึ่งรวมถึงรายการต่อไปนี้
นักพัฒนาแอปมีสิทธิ์เข้าถึง Framework API เดียวกันกับที่แอปของระบบ Android ใช้ได้อย่างเต็มที่
แอประบบ
Android มาพร้อมชุดแอปหลักสำหรับอีเมล การรับส่งข้อความ SMS ปฏิทิน
การท่องอินเทอร์เน็ต รายชื่อติดต่อ และอื่นๆ แอปที่รวมอยู่ในแพลตฟอร์มจะไม่มีสถานะพิเศษในกลุ่มแอปที่ผู้ใช้เลือกติดตั้ง ดังนั้น แอปของบุคคลที่สามจึงสามารถกลายเป็นเว็บเบราว์เซอร์, โปรแกรมรับส่งข้อความ SMS หรือแม้แต่แป้นพิมพ์เริ่มต้นของผู้ใช้ได้
โดยมีข้อยกเว้นบางอย่าง เช่น แอปการตั้งค่าของระบบ
แอปของระบบทำหน้าที่ทั้งเป็นแอปสำหรับผู้ใช้และมอบความสามารถหลัก
ที่นักพัฒนาแอปสามารถเข้าถึงได้จากแอปของตนเอง ตัวอย่างเช่น หาก
คุณต้องการให้แอปส่งข้อความ SMS คุณก็ไม่จำเป็นต้องสร้างฟังก์ชันการทำงานนั้นด้วยตนเอง คุณสามารถเรียกใช้แอป SMS ที่ติดตั้งไว้แล้วแทนเพื่อส่งข้อความไปยังผู้รับที่คุณระบุ
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Platform architecture\n\nAndroid is an open source, Linux-based software stack created for a wide\narray of devices and form factors. Figure 1 shows the major\ncomponents of the Android platform.\n\n\n**Figure 1.** The Android software stack.\n\nLinux kernel\n------------\n\n\nThe foundation of the Android platform is the Linux kernel. For example,\n[the Android Runtime (ART)](#art) relies on the Linux kernel for\nunderlying functionalities such as threading and low-level memory management.\n\n\nUsing a Linux kernel lets Android take advantage of [key\nsecurity features](https://source.android.com/security/overview/kernel-security.html) and lets device manufacturers develop hardware\ndrivers for a well-known kernel.\n\nHardware abstraction layer (HAL)\n--------------------------------\n\n\nThe [hardware abstraction layer (HAL)](https://source.android.com/devices/architecture/hal) provides standard interfaces that expose\ndevice hardware capabilities to the higher-level [Java API framework](#api-framework). The HAL consists of multiple library\nmodules, each of which implements an interface for a specific type of hardware\ncomponent, such as the [camera](https://source.android.com/devices/camera/index.html) or [Bluetooth](https://source.android.com/devices/bluetooth.html) module.\nWhen a framework API makes a call to access device hardware, the Android\nsystem loads the library module for that hardware component.\n\nAndroid runtime\n---------------\n\n\nFor devices running Android version 5.0 (API level 21) or higher, each app\nruns in its own process and with its own instance of the [Android Runtime\n(ART)](https://source.android.com/devices/tech/dalvik/index.html). ART is written to run multiple virtual machines on low-memory\ndevices by executing Dalvik Executable\nformat (DEX) files, a bytecode format designed specifically for\nAndroid that's optimized for a minimal memory footprint. Build tools, such\nas [`d8`](/studio/command-line/d8), compile\nJava sources into DEX bytecode, which can run on the Android platform.\n\n\nSome of the major features of ART include the following:\n\n- Ahead-of-time (AOT) and just-in-time (JIT) compilation\n- Optimized garbage collection (GC)\n- On Android 9 (API level 28) and higher, [conversion](/about/versions/pie/android-9.0#art-aot-dex) of an app package's DEX files to more compact machine code\n- Better debugging support, including a dedicated sampling profiler, detailed diagnostic exceptions and crash reporting, and the ability to set watchpoints to monitor specific fields\n\n\nPrior to Android version 5.0 (API level 21), Dalvik was the Android runtime.\nIf your app runs well on ART, then it can work on Dalvik as well, but\n[the reverse might not be\ntrue](/guide/practices/verifying-apps-art).\n\n\nAndroid also includes a set of core runtime libraries that provide most of\nthe functionality of the Java programming language, including some [Java 8 language features](/guide/platform/j8-jack), that the Java\nAPI framework uses.\n\nNative C/C++ libraries\n----------------------\n\n\nMany core Android system components and services, such as ART and HAL, are\nbuilt from native code that requires native libraries written in C and C++.\nThe Android platform provides Java framework APIs to expose the functionality\nof some of these native libraries to apps. For example, you can access\n[OpenGL ES](/develop/ui/views/graphics/opengl/about-opengl) through the\nAndroid framework's [Java OpenGL API](/reference/android/opengl/package-summary) to add\nsupport for drawing and manipulating 2D and 3D graphics in your app.\n\n\nIf you are developing an app that requires C or C++ code, you can use the\n[Android NDK](/ndk) to access some of these [native platform libraries](/ndk/guides/stable_apis) directly from\nyour native code.\n\nJava API framework\n------------------\n\n\nThe entire feature-set of the Android OS is available to you through APIs\nwritten in the Java language. These APIs form the building blocks you need to\ncreate Android apps by simplifying the reuse of core, modular system\ncomponents and services, which include the following:\n\n- A rich and extensible [view\n system](/guide/topics/ui/overview) you can use to build an app's UI, including lists, grids, text boxes, buttons, and even an embeddable web browser\n- A [resource manager](/guide/topics/resources/overview), providing access to non-code resources such as localized strings, graphics, and layout files\n- A [notification\n manager](/guide/topics/ui/notifiers/notifications) that enables all apps to display custom alerts in the status bar\n- An [activity manager](/guide/components/activities/intro-activities) that manages the lifecycle of apps and provides a common [navigation back stack](/guide/components/tasks-and-back-stack)\n- [Content\n providers](/guide/topics/providers/content-providers) that enable apps to access data from other apps, such as the Contacts app, or to share their own data\n\n\nDevelopers have full access to the same [framework APIs](/reference/packages) that Android system apps use.\n\nSystem apps\n-----------\n\n\nAndroid comes with a set of core apps for email, SMS messaging, calendars,\ninternet browsing, contacts, and more. Apps included with the platform have\nno special status among the apps the user chooses to install. So, a\nthird-party app can become the user's default web browser, SMS messenger, or\neven the default keyboard. Some exceptions apply, such as the system's\nSettings app.\n\n\nThe system apps function both as apps for users and to provide key\ncapabilities that developers can access from their own app. For example, if\nyou want your app to deliver SMS messages, you don't need to build that\nfunctionality yourself. You can instead invoke whichever SMS app is already\ninstalled to deliver a message to the recipient you specify."]]