- Как включить отладку по USB на Android
- Включение отладки по USB на Android телефоне или планшете
- Видео инструкция
- Android Debug Bridge (ADB) Connect to Device over USB, WiFi
- What is Android Debug Bridge (ADB)?
- USB debugging and ADB Configuration-
- How to Connect to an Emulator
- How to Connect Android Device with ADB (Android Debug Bridge)
- How to Configuring ADB for Wi-Fi Support
- Remote debug Android devices
- # Step 1: Discover your Android device
- # Troubleshooting: DevTools is not detecting the Android device
- # Step 2: Debug content on your Android device from your development machine
- # More actions: pause, focus, reload, or close a tab
- # Inspect elements
- # Screencast your Android screen to your development machine
Как включить отладку по USB на Android
Включенная отладка по USB на Android устройстве может потребоваться для самых разных целей: прежде всего, для выполнения команд в adb shell (прошивка, кастомный рекавери, запись экрана), но не только: например, включенная функция может пригодиться и для восстановления данных на Android.
В этой пошаговой инструкции подробно о том, как включить отладку по USB на Android 5-7 (в общем-то, то же самое будет и на версиях 4.0-4.4), в видео показано включение отладки на Android 9 Pie и на смартфонах Samsung Galaxy.
Скриншоты и пункты меню в руководстве соответствуют почти чистой ОС Android 6 на телефоне Moto (то же самое будет на Nexus и Pixel), но принципиальной разницы в действиях на других устройствах, таких как Samsung, LG, Lenovo, Meizu, Xiaomi или Huawei не будет, все действия практически те же самые, также в статье присутствуют текстовые пути для настроек на других версиях Android и марках телефонов.
Включение отладки по USB на Android телефоне или планшете
Для того, чтобы появилась возможность включить отладку по USB, сначала необходимо включить режим разработчика Android, сделать это можно следующим образом.
- Зайдите в Настройки и нажмите пункт «О телефоне» или «О планшете», на Samsung — «Сведения о телефоне» — «Сведения о ПО». На чистом Android 9.0 зайдите в пункт «Система» — «О телефоне».
- Найдите пункт «Номер сборки» (на телефонах Xiaomi и некоторых других — пункт «Версия MIUI») и несколько раз нажимайте по нему, пока не увидите сообщение о том, что вы стали разработчиком.
Теперь в меню «Настройки» вашего телефона появится новый пункт «Для разработчиков» и можно переходить к следующему этапу (может быть полезно: Как включить и отключить режим разработчика на Android).
Процесс включения отладки по USB также состоит из нескольких очень простых шагов:
- Зайдите в «Настройки» — «Для разработчиков». На Android 9, например, на Nokia — в Настройки — Система — Дополнительно — Для разработчиков. На некоторых китайских телефонах, например, на Xiaomi — в Настройки — Дополнительно — Для разработчиков или Настройки — Расширенные настройки — Для разработчиков. Если вверху страницы есть переключатель, который установлен в положение «Выкл», переключите его в «Вкл».
- В разделе «Отладка» включите пункт «Отладка по USB», чтобы включить режим отладки по USB.
- Подтвердите включение отладки в окне «Разрешить отладку по USB», внимательно прочитав предупреждение.
На этом всё готово — отладка по USB на вашем Android телефоне включена и ее можно использовать с нужными вам целями.
Видео инструкция
В дальнейшем, вы можете отключить отладку в том же разделе меню, а при необходимости — отключить и убрать из меню Настроек пункт «Для разработчиков» (ссылка на инструкцию с необходимыми действиями была приведена выше).
А вдруг и это будет интересно:
17.07.2021 в 22:27
Здравствуйте! С помощью «Для разработчиков» и «Отладки USB» я удалял проблему связи, через кабель компьютер видел и изображения, и видео, и я оперировал ими. И это прекрасно!
Но есть пару но.
1. На всё время данной связи связи с интернетом не было (пока я работал с файлами через кабель, файлы, направляемые ко мне как и всегда через вай-фай, отсутствовали. И как только восстановил через Google связь, файлы гурьбой прилетели).
2. Второе но — после восстановления интернета связь через кабель с компьютером опять отсутствует. Как и ранее.
Есть ли вариант разовой настройки на связи одновременно и с интернетом, и компьютером по USB навсегда, кто знает?
28.09.2021 в 17:24
13.10.2021 в 18:30
Спасибо, никак не мог разобраться с просмотром файлов с телефона Redmi 4 на ПК, очень помогли.
Источник
Android Debug Bridge (ADB) Connect to Device over USB, WiFi
Updated October 7, 2021
What is Android Debug Bridge (ADB)?
Android Debug Bridge (ADB) is a command-line tool that allows you to communicate with a device. It is used to bridge communication between an emulator instance (Android device) and the background running daemon process (server). It helps you perform different actions like installing or debugging a device and run various commands on a device by providing access to a Unix shell.
Using any real device for mobile automation Testing has always been a challenge for testers. But, Android offers a handful of solutions to connect a real device over USB (Universal Serial Bus), i.e., Android Debug Bridge (ADB).
In this tutorial, you will learn-
USB debugging and ADB Configuration-
APPIUM offers an advantage to execute test on real devices. But prior to run the test, we need to setup following pre-requisite.
- USB debugging should be enabled
- ADB configuration
- Desired capability setup as per the hardware changes.
Here we will see both, connecting to emulator as well as with real device for testing. See steps below for connecting to an emulator.
How to Connect to an Emulator
Pre-Requisite- SDK (Software Development Kit) should be installed on the machine. ADB in Android is packaged with Google’s Android SDK (Software Development Kit).
Steps to enable ADB from SDK Manager.
Step 1) Open Android SDK folder
Step 2) Double click on SDK Manager
Step 3) From the list of all packages select Tools and mark the checkbox for
- Android SDK Tools and
- Android SDK Platform-tools.
How to Connect Android Device with ADB (Android Debug Bridge)
Step 1) Enable USB Debugging on your device
Enable USB debugging option from ‘Developer Option’ in Android phone. Now, connect your Android device to the computer using USB cable.
Step 2) Go to the Android SDK folder
Open the local folder where Android SDK files has been saved ‘Android SDK >> Platform-tools’ eg: C:\android-sdk\platform-tools
Step 3) Open the Command window
Inside folder hold Shift + Right click menu >> Select ‘Open command window here’ option.
It will open the folder using command prompt.
Note– you can also open the folder path directly from the Run command in command prompt.
This command window will directly open the folder in command prompt window.
Step 4) Connect an external Android device
Now, prior to check the device, user have to connect an external Android device (mobile phone). To connect use the device USB cable connector to the system. Then in above command prompt type command-
It will display all list of all the connected devices.
But, prior to this we should check that ADB server. Check whether it is running as background process or not. Just open the command prompt from above mentioned procedure and write ‘adb’ and press enter. It should display all the adb’s process running.
When server starts, it always bind the local TCP port 5037. All ADB clients listen to 5037 TCP port to communicate with server request.
Now, the running ADB server can scan all connected emulator or device instances by scanning the port.
Always remember that ADB daemon runs on odd numbered port between the ranges of 5555 to 5558.
ADB daemon process runs with console connection that acquires even number port for connection.
For example: If single device connected then server automatically scan the device and get connected but if multiple device or emulator running the user need to give ADB connect to device USB command line instruction to connect.
The emulator instance connected on odd numbered port 5557 has the same console running over even numbered 5556 port ie. Each running devices has 1 odd and 1 even connected port.
Command to detect all connected device –
Command detecting a single device from multiple connected devices-
It will detect the adb connection for device -5554 and install the application.
So, this way user can set up a successful connection to access ADB USB connect instances using ADB commands.
How to Configuring ADB for Wi-Fi Support
Just like configuring ADB connect USB, user can also configure ADB over wi-fi.
Pre-requisite
- Both Android device and the host computer should be connected to same wireless network and
- Device Bluetooth option should disabled.
Steps to connect-
- Connect device using USB cable to the host computer. Confirm USB debugging is enabled in device.
- Set target device to connect TCP/IP on port 5555
- Now, disconnect the USB cable from the device.
- In Android device find the IP address from Settings >> wi-fi Setting >> Advanced >> IP Address.Use the same Android Debug Bridge IP address to connect the device via ADB connect device USB connection
Hence, the final configuration done and ‘adb’ successfully configured over wireless network.
NOTE- If any connection error occurred just reset or kill the adb host connection. For that use following command
Источник
Remote debug Android devices
Published on Monday, April 13, 2015
Technically, I’m a writer
Remote debug live content on an Android device from your Windows, Mac, or Linux computer. This tutorial teaches you how to:
- Set up your Android device for remote debugging, and discover it from your development machine.
- Inspect and debug live content on your Android device from your development machine.
- Screencast content from your Android device onto a DevTools instance on your development machine.
Figure 1. Remote Debugging lets you inspect a page running on an Android device from your development machine.
# Step 1: Discover your Android device
The workflow below works for most users. See Troubleshooting: DevTools is not detecting the Android device for more help.
Open the Developer Options screen on your Android. See Configure On-Device Developer Options.
Select Enable USB Debugging.
On your development machine, open Chrome.
Go to chrome://inspect#devices .
Make sure that the Discover USB devices checkbox is enabled.
Figure 2. The Discover USB Devices checkbox is enabled
Connect your Android device directly to your development machine using a USB cable. The first time you do this, you usually see that DevTools has detected an offline device. If you see the model name of your Android device, then DevTools has successfully established the connection to your device. Continue to Step 2.
Figure 3. The Remote Target has successfully detected an offline device that is pending authorization
If your device is showing up as Offline, accept the Allow USB Debugging permission prompt on your Android device.
# Troubleshooting: DevTools is not detecting the Android device
Make sure that your hardware is set up correctly:
- If you’re using a USB hub, try connecting your Android device directly to your development machine instead.
- Try unplugging the USB cable between your Android device and development machine, and then plugging it back in. Do it while your Android and development machine screens are unlocked.
- Make sure that your USB cable works. You should be able to inspect files on your Android device from your development machine.
Make sure that your software is set up correctly:
- If your development machine is running Windows, try manually installing the USB drivers for your Android device. See Install OEM USB Drivers.
- Some combinations of Windows and Android devices (especially Samsung) require extra set up. See Chrome DevTools Devices does not detect device when plugged in.
If you don’t see the Allow USB Debugging prompt on your Android device try:
- Disconnecting and then re-connecting the USB cable while DevTools is in focus on your development machine and your Android homescreen is showing. In other words, sometimes the prompt doesn’t show up when your Android or development machine screens are locked.
- Updating the display settings for your Android device and development machine so that they never go to sleep.
- Setting Android’s USB mode to PTP. See Galaxy S4 does not show Authorize USB debugging dialog box.
- Select Revoke USB Debugging Authorizations from the Developer Options screen on your Android device to reset it to a fresh state.
If you find a solution that is not mentioned in this section or in Chrome DevTools Devices does not detect device when plugged in, please add an answer to that Stack Overflow question, or open an issue in the webfundamentals repository!
# Step 2: Debug content on your Android device from your development machine
Open Chrome on your Android device.
In the chrome://inspect/#devices , you see your Android device’s model name, followed by its serial number. Below that, you can see the version of Chrome that’s running on the device, with the version number in parentheses. Each open Chrome tab gets its own section. You can interact with that tab from this section. If there are any apps using WebView, you see a section for each of those apps, too. In Figure 5 there are no tabs or WebViews open.
Figure 4. A connected remote device
In the Open tab with url text box, enter a URL and then click Open. The page opens in a new tab on your Android device.
Click Inspect next to the URL that you just opened. A new DevTools instance opens. The version of Chrome running on your Android device determines the version of DevTools that opens on your development machine. So, if your Android device is running a very old version of Chrome, the DevTools instance may look very different than what you’re used to.
# More actions: pause, focus, reload, or close a tab
Below the URL you can find a menu to pause, focus, reload or close a tab.
Figure 5. The menu for pausing, reloading, focusing, or closing a tab
# Inspect elements
Go to the Elements panel of your DevTools instance, and hover over an element to highlight it in the viewport of your Android device.
You can also tap an element on your Android device screen to select it in the Elements panel. Click Select Element on your DevTools instance, and then tap the element on your Android device screen. Note that Select Element is disabled after the first touch, so you need to re-enable it every time you want to use this feature.
# Screencast your Android screen to your development machine
Click Toggle Screencast to view the content of your Android device in your DevTools instance.
You can interact with the screencast in multiple ways:
- Clicks are translated into taps, firing proper touch events on the device.
- Keystrokes on your computer are sent to the device.
- To simulate a pinch gesture, hold Shift while dragging.
- To scroll, use your trackpad or mouse wheel, or fling with your mouse pointer.
Some notes on screencasts:
- Screencasts only display page content. Transparent portions of the screencast represent device interfaces, such as the Chrome address bar, the Android status bar, or the Android keyboard.
- Screencasts negatively affect frame rates. Disable screencasting while measuring scrolls or animations to get a more accurate picture of your page’s performance.
- If your Android device screen locks, the content of your screencast disappears. Unlock your Android device screen to automatically resume the screencast.
Last updated: Monday, April 13, 2015 • Improve article
Источник