แก้ไขข้อบกพร่องของโค้ดแพลตฟอร์ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Android Studio for Platform (ASfP) มีดีบักเกอร์ที่มีประสิทธิภาพซึ่งช่วยให้คุณทำสิ่งต่อไปนี้ได้
- เลือกอุปกรณ์ที่จะทำการแก้ไขข้อบกพร่อง
- ตั้งค่าเบรกพอยต์ในโค้ด Java, Kotlin และ C/C++
- ตรวจสอบตัวแปรและประเมินนิพจน์ขณะรันไทม์
ก่อนใช้ดีบักเกอร์ คุณต้องแฟลชบิลด์ไปยังอุปกรณ์หรือโปรแกรมจำลอง
การแก้ไขข้อบกพร่องของกระบวนการแอป (Java/Kotlin)
วิธีแก้ไขข้อบกพร่องในกระบวนการแอปพลิเคชัน Java หรือ Kotlin
ตั้งค่าเบรกพอยต์ในโค้ด Java หรือ Kotlin ภายใน ASfP
เลือกเรียกใช้ > แนบดีบักเกอร์กับกระบวนการ Android จากเมนู
ในกล่องโต้ตอบเลือกกระบวนการ ให้ตรวจสอบว่าได้ตั้งค่าประเภทการแก้ไขข้อบกพร่องเป็น
Java เท่านั้น
เลือกอุปกรณ์จากรายการ
เลือกกระบวนการแอปพลิเคชันที่เฉพาะเจาะจงที่คุณต้องการแก้ไขข้อบกพร่อง
คลิกตกลง
โต้ตอบกับแอปพลิเคชันในอุปกรณ์เพื่อเข้าถึงจุดพัก
การแก้ไขข้อบกพร่องของกระบวนการของระบบ (C/C++)
หากต้องการแก้ไขข้อบกพร่องของกระบวนการของระบบที่เขียนด้วย C หรือ C++ ให้ทำดังนี้
ตรวจสอบว่าคุณมีอุปกรณ์หรือโปรแกรมจำลองที่ทำงานอยู่เพียงเครื่องเดียว
เปิดเทอร์มินัลและเรียกใช้ adb root
จากรูทการชำระเงินของ AOSP: bash
adb root
ตั้งค่าเบรกพอยต์ในโค้ด C/C++ ภายใน ASfP
เลือกเรียกใช้ > แนบดีบักเกอร์กับกระบวนการ Android จากเมนู
ในกล่องโต้ตอบเลือกกระบวนการ ให้เปลี่ยนประเภทการแก้ไขข้อบกพร่องเป็นเนทีฟ
เท่านั้นหรือคู่ (Java + เนทีฟ)
เลือกช่องแสดงกระบวนการทั้งหมดเพื่อดูกระบวนการของระบบ
เลือกอุปกรณ์จากรายการ
เลือกกระบวนการของระบบที่ต้องการแก้ไขข้อบกพร่อง (เช่น
surfaceflinger
หรือ system_server
)
คลิกตกลง
ดีบักเกอร์จะแนบไปกับกระบวนการ โต้ตอบกับอุปกรณ์เพื่อเข้าถึง
เบรกพอยต์
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-09-04 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-09-04 UTC"],[],[],null,["Android Studio for Platform (ASfP) provides a powerful debugger that lets you:\n\n- Select a device to debug on.\n- Set breakpoints in your Java, Kotlin, and C/C++ code.\n- Examine variables and evaluate expressions at runtime.\n\nBefore you use the debugger, you must flash your build to a device or emulator.\n\nApp process (Java/Kotlin) debugging\n\nTo debug a Java or Kotlin application process:\n\n1. Set breakpoints in your Java or Kotlin code within ASfP.\n\n2. Select **Run \\\u003e Attach Debugger to Android Process** from the menu.\n\n3. In the **Choose Process** dialog, make sure the **Debug type** is set to\n **Java Only**.\n\n4. Select your device from the list.\n\n5. Choose the specific application process you want to debug.\n\n6. Click **OK**.\n\n7. Interact with the application on your device to hit the breakpoints.\n\nSystem process (C/C++) debugging\n\nTo debug a system process written in C or C++:\n\n1. Verify that you have only one device or emulator running.\n\n2. Open a terminal and run `adb root` from your AOSP checkout root: `bash\n adb root`\n\n\u003c!-- --\u003e\n\n1. Set breakpoints in your C/C++ code within ASfP.\n\n2. Select **Run \\\u003e Attach Debugger to Android Process** from the menu.\n\n3. In the **Choose Process** dialog, change the **Debug type** to **Native\n Only** or **Dual (Java + Native)**.\n\n4. Check the **Show all processes** box to see system processes.\n\n5. Select your device from the list.\n\n6. Choose the specific system process you want to debug (such as\n `surfaceflinger` or `system_server`).\n\n7. Click **OK**.\n\n8. The debugger attaches to the process. Interact with the device to hit your\n breakpoints."]]