プラットフォーム コードをデバッグする
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
Android Studio for Platform(ASfP)には、以下の処理などを行うことができる強力なデバッガが用意されています。
- デバッグするデバイスを選択します。
- Java、Kotlin、C / C++ のコード内にブレークポイントを設定する。
- 実行時に変数や式を検証する。
デバッガを使用する前に、ビルドをデバイスまたはエミュレータにフラッシュする必要があります。
アプリ プロセス(Java/Kotlin)のデバッグ
Java アプリケーション プロセスまたは Kotlin アプリケーション プロセスをデバッグするには:
ASfP 内の Java または Kotlin コードにブレークポイントを設定します。
メニューから [Run] > [Attach Debugger to Android Process] を選択します。
[Choose Process] ダイアログで、[Debug type] が [Java Only] に設定されていることを確認します。
リストからデバイスを選択します。
デバッグする特定のアプリケーション プロセスを選択します。
[OK] をクリックします。
デバイスでアプリケーションを操作して、ブレークポイントにヒットさせます。
システム プロセス(C/C++)のデバッグ
C または C++ で記述されたシステム プロセスをデバッグするには:
実行中のデバイスまたはエミュレータが 1 つだけであることを確認します。
ターミナルを開き、AOSP チェックアウトのルートから adb root
を実行します。bash
adb root
ASfP 内の C/C++ コードにブレークポイントを設定します。
メニューから [Run] > [Attach Debugger to Android Process] を選択します。
[Choose Process] ダイアログで、[Debug type] を [Native Only] または [Dual (Java + Native)] に変更します。
[Show all processes] チェックボックスをオンにすると、システム プロセスが表示されます。
リストからデバイスを選択します。
デバッグする特定のシステム プロセス(surfaceflinger
や system_server
など)を選択します。
[OK] をクリックします。
デバッガがプロセスにアタッチされます。デバイスを操作してブレークポイントに到達します。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。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."]]