Android 的遠端偵錯功能
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
由於開發環境與執行環境各異,部分問題只會在特定實體裝置上發生。
此時,遠端程式碼偵錯功能就顯得至關重要。這項功能可協助您迅速找出問題,節省許多寶貴時間。
幸好在 Cocos Creator,執行遠端程式碼偵錯非常簡單。
您只要按照以下 3 個步驟操作,即可在實體裝置上執行遠端程式碼偵錯功能:
確認 Android 裝置與您用來偵錯的電腦使用相同的 LAN (請勿在偵錯期間啟用 Proxy,否則連線可能會失敗)。
在 Cocos Creator 的「Build」面板中選取 Android 平台,並勾選「Debug」模式,接著即可建構及執行。
使用 Chrome 瀏覽器前往以下網址,開啟用於執行遠端偵錯的 Chrome 開發人員工具 (您需要將 <device_LAN_IP>
替換為正確的行動裝置 IP 位址)。接下來,您就可以開始對專案的 TypeScript 程式碼進行遠端偵錯。
devtools://devtools/bundled/js_app.html?v8only=true&ws=<device_LAN_IP>:6086/00010002-0003-4004-8005-000600070008

如需詳細操作說明,請參閱官方的 Cocos Creator 說明文件。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[null,null,["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Remote debugging on Android\n\nDue to the differences between development and running environments, some\nproblems only occur on specific physical devices.\n\nAt this time, remote code debugging is very important. It can help you to locate\nthe problem quickly, saving you lots of time.\n\nFortunately, remote code debugging is very easy in Cocos Creator.\n\nTo perform remote code debugging on physical devices, just follow these 3 steps:\n\n1. Make sure the Android device is on the same LAN as the computer that you are\n using for debugging. (**Do not enable proxy during debugging, otherwise the\n connection may fail.**)\n\n2. Select the Android platform and check **Debug mode** in the **Build** panel\n of Cocos Creator, then build and run.\n\n3. Open the Chrome devtools for remote debugging by visiting the following\n address in the Chrome browser. (You'll need to replace `\u003cdevice_LAN_IP\u003e`\n with the correct mobile device's IP address.) You can then start the remote\n debugging on TypeScript code in your project.\n\n devtools://devtools/bundled/js_app.html?v8only=true&ws=\u003cdevice_LAN_IP\u003e:6086/00010002-0003-4004-8005-000600070008\n\nFor more detailed instructions, you can take a look at the official [Cocos\nCreator\ndocumentation](https://docs.cocos.com/creator/manual/en/editor/publish/debug-jsb.html)."]]