Men-debug kode platform
Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Android Studio untuk Platform (ASfP) menyediakan debugger canggih yang memungkinkan Anda:
- Pilih perangkat untuk men-debug.
- Menetapkan titik henti sementara dalam kode Java, Kotlin, dan C/C++.
- Memeriksa variabel dan mengevaluasi ekspresi pada waktu proses.
Sebelum menggunakan debugger, Anda harus mem-flash build ke perangkat atau emulator.
Proses debug proses aplikasi (Java/Kotlin)
Untuk men-debug proses aplikasi Java atau Kotlin:
Tetapkan titik henti sementara dalam kode Java atau Kotlin Anda di dalam ASfP.
Pilih Run > Attach Debugger to Android Process dari menu.
Pada dialog Choose Process, pastikan Debug type disetel ke
Java Only.
Pilih perangkat Anda dari daftar.
Pilih proses aplikasi tertentu yang ingin Anda debug.
Klik OK.
Berinteraksi dengan aplikasi di perangkat Anda untuk mencapai titik henti sementara.
Proses sistem (C/C++) debugging
Untuk men-debug proses sistem yang ditulis dalam C atau C++:
Pastikan Anda hanya menjalankan satu perangkat atau emulator.
Buka terminal dan jalankan adb root
dari root checkout AOSP Anda: bash
adb root
Tetapkan titik henti sementara dalam kode C/C++ Anda di dalam ASfP.
Pilih Run > Attach Debugger to Android Process dari menu.
Pada dialog Choose Process, ubah Debug type menjadi Native
Only atau Dual (Java + Native).
Centang kotak Tampilkan semua proses untuk melihat proses sistem.
Pilih perangkat Anda dari daftar.
Pilih proses sistem tertentu yang ingin Anda debug (seperti
surfaceflinger
atau system_server
).
Klik OK.
Debugger terhubung ke proses. Berinteraksi dengan perangkat untuk mencapai titik henti sementara.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-09-04 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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."]]