aboutsummaryrefslogtreecommitdiff
path: root/files/ru/tools/remote_debugging/firefox_for_android/index.html
blob: 6bcd7b2b478c089a13edb690c2244669b016ceee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
title: Remotely debugging Firefox for Android
slug: Tools/Remote_Debugging/Firefox_for_Android
translation_of: Tools/Remote_Debugging/Firefox_for_Android
---
<div>{{ToolsSidebar}}</div><p>This guide explains how to use <a href="/docs/Tools/Remote_Debugging">remote debugging </a>to inspect or debug code running in <a href="/en-US/docs/Mozilla/Firefox_for_Android">Firefox for Android </a>over USB.</p>

<div class="note">
<p>Мы недавно сильно упростили процесс подключения инструментов разработки к Firefox для Android. Если вы работаете с Firefox Desktop 36 или новее, и Firefox для Android 35 или новее, то <a href="/en-US/docs/Tools/Remote_Debugging/Debugging_Firefox_for_Android_with_WebIDE">попробуйте новый процесс</a> вместо этого.</p>
</div>

<p><img alt="" src="https://mdn.mozillademos.org/files/5833/remote-debugging-overview.png" style="display: block; margin-left: auto; margin-right: auto;"></p>

<p>This guide's split into two parts: the first part, "Prerequisites" covers stuff you only need to do once, while the second part, "Connecting", covers stuff you need to do each time you connect the device. </p>

<h2 id="Prerequisites">Prerequisites</h2>

<p>First, you'll need:</p>

<ul>
 <li>a desktop or laptop computer with Firefox 15 or higher running on it</li>
 <li>an Android device <a href="https://support.mozilla.org/en-US/kb/will-firefox-work-my-mobile-device" title="https://support.mozilla.org/en-US/kb/will-firefox-work-my-mobile-device">capable of running Firefox for Android</a> with Firefox for Android 15 or higher running on it</li>
 <li>a USB cable to connect the two devices</li>
</ul>

<h3 id="ADB_setup">ADB setup</h3>

<p>Next, you'll need to get the desktop and the Android device talking to each other using the <a href="https://developer.android.com/tools/help/adb.html" title="https://developer.android.com/tools/help/adb.html">adb</a> command-line tool.</p>

<h4 class="note" id="On_the_Android_device">On the Android device</h4>

<ul>
 <li><a href="http://developer.android.com/guide/developing/device.html#setting-up" title="http://developer.android.com/guide/developing/device.html#setting-up">Enable USB debugging (step 2 of this link only)</a>.</li>
 <li>Attach the device to the desktop via USB.</li>
</ul>

<h4 class="note" id="On_the_desktop">On the desktop</h4>

<ul>
 <li>Установите корректную версию  <a href="http://developer.android.com/sdk/index.html" title="http://developer.android.com/sdk/index.html">Android SDK</a> для вашего устройства.</li>
 <li>С помощью Android SDK установите инструменты платформы <a href="http://developer.android.com/sdk/installing.html#components" title="http://developer.android.com/sdk/installing.html#components">Android Platform Tools</a>.</li>
 <li>Платформа Android Tools устанавливает adb (Android Debug Bridge) в директорию "Platform-инструментов", в которой установлена Android SDK. Убедитесь, что каталог "инструментов платформы" находится в переменной окружения path.</li>
</ul>

<p>To check it worked, open up a command shell on the desktop and type:</p>

<pre>adb devices</pre>

<p>You should see some output like:</p>

<pre>List of devices attached
51800F220F01564 device
</pre>

<p>(The long hex string will be different.)</p>

<p>If you do, then <code>adb</code> has found your device and you've successfully set up ADB.</p>

<h3 id="Enable_remote_debugging">Enable remote debugging</h3>

<p>Next, you need to enable remote debugging on both the Android device and the desktop.</p>

<h4 id="Firefox_for_Android_24_and_earlier">Firefox for Android 24 and earlier</h4>

<p>To enable remote debugging on the device, you need to set the <code>devtools.debugger.remote-enabled</code> preference to <code>true</code>.</p>

<p>Go to <code>about:config</code> in Firefox for Android, type "devtools" into the search box and press the Search key. You'll see all the devtools preferences. Find the <code>devtools.debugger.remote-enabled</code> preference, and press "Toggle".</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5803/remote-debugger-about-config-toggle.png" style="display: block; margin-left: auto; margin-right: auto;"></p>

<h4 class="note" id="Firefox_for_Android_25_and_later">Firefox for Android 25 and later</h4>

<p>On Firefox for Android 25 and later, there's a menu item to enable remote debugging. Open the menu, select "Settings", then "Developer tools" (on some Android devices you may need to select "More" to see the "Settings" option). Check the "Remote debugging" box:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5829/remote-debugging-device-enable.png" style="display: block; margin-left: auto; margin-right: auto;"></p>

<p>The browser will display a notification reminding you to set up port forwarding, which we'll do later on.</p>

<h4 id="On_the_desktop_2">On the desktop</h4>

<p>On the desktop, remote debugging is enabled by a setting in the Toolbox. <a href="/en-US/docs/Tools_Toolbox" title="/en-US/docs/Tools_Toolbox">Open the Toolbox</a>, click the "Settings" button in the <a href="/en-US/docs/Tools_Toolbox#Toolbar" title="/en-US/docs/Tools_Toolbox#Toolbar">toolbar</a>, and check "Enable remote debugging" in the <a href="/en-US/docs/Tools_Toolbox#Settings" title="/en-US/docs/Tools_Toolbox#Settings">Settings </a>tab:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5827/remote-debugger-toolbox-settings.png" style="display: block; margin-left: auto; margin-right: auto;"></p>

<div class="Note">If you're using a version of Firefox older than 27, you'll need to restart the browser for the setting to take effect.</div>

<p>You'll then see a new option in the Web Developer menu labeled "Connect...":</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5811/remote-debugging-connect-menuitem.png" style="display: block; margin-left: auto; margin-right: auto;"></p>

<h2 id="Connecting">Connecting</h2>

<p>Now you can connect the remote debugging tools to the device. First, attach the device to the desktop with a USB cable, if you haven't already.</p>

<h4 class="note" id="On_the_desktop_3">On the desktop</h4>

<p>For Firefox for Android 35 and later, go to a command prompt, and type:</p>

<pre>adb forward tcp:6000 localfilesystem:/data/data/org.mozilla.firefox/firefox-debugger-socket</pre>

<p>For Firefox for Android builds in other channels, the <code>org.mozilla.firefox</code> part should be changed to:</p>

<ul>
 <li><code>org.mozilla.firefox_beta</code> for Beta</li>
 <li><code>org.mozilla.fennec_aurora</code> for Aurora</li>
 <li><code>org.mozilla.fennec</code> for Nightly</li>
</ul>

<p>For Firefox for Android 34 and earlier, type:</p>

<pre>adb forward tcp:6000 tcp:6000</pre>

<p>(If you've changed the value the Android device uses for a debugging port, you'll need to adjust this accordingly.)</p>

<p>For Firefox OS, type:</p>

<pre>adb forward tcp:6000 localfilesystem:/data/local/debugger-socket</pre>

<p>You'll need to reissue this command each time you physically attach desktop and device with the USB cable.</p>

<p>Then go to the Web Developer menu on Firefox, and select "Connect...". You'll see a page that looks like this:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5813/remote-debugging-desktop-connect.png" style="display: block; margin-left: auto; margin-right: auto;">Unless you've changed the port numbers, choose 6000 and press the "Connect" button.</p>

<h4 class="note" id="On_the_Android_device_2">On the Android device</h4>

<p>Next you'll see a dialog on the Android device asking you to confirm the connection:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5815/remote-debugging-device-connect.png" style="display: block; margin-left: auto; margin-right: auto;">Press "OK". The desktop waits for a few seconds to give you time to acknowledge this dialog: if it times out, just press "Connect" in the desktop dialog again.</p>

<h4 class="note" id="On_the_desktop_4">On the desktop</h4>

<p>Next, the desktop shows you a dialog that looks something like this:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5819/remote-debugging-desktop-select-target.png" style="display: block; margin-left: auto; margin-right: auto;">This is asking whether you want to debug web content running in a browser tab, or to debug the browser code itself.</p>

<ul>
 <li>You'll see one entry under "Available remote tabs" for each open tab, and clicking it will attach the debugging tools to the web content hosted by that tab. If you want to debug your web content, you'll choose the relevant content tab.</li>
 <li>You'll see one entry under "Available remote processes": this is the browser process itself. You'll choose this option if you want to debug the browser's own code.</li>
</ul>

<p>Let's choose to attach to the mozilla.org website. The Toolbox will open in its own window, attached to the Firefox for Android tab that's currently hosting mozilla.org:</p>

<p><img alt="" src="https://mdn.mozillademos.org/files/5821/remote-debugging-console.png" style="display: block; margin-left: auto; margin-right: auto;"></p>

<p>The Toolbox, and the tools it hosts, work in just the same way as they do when attached to local content.<img alt="" src="https://mdn.mozillademos.org/files/5823/remote-debugging-debugger.png" style="display: block; margin-left: auto; margin-right: auto;"></p>