The steps to enable USB debugging depend on the version of Android running on the target device, as indicated in the following table:
Android Device
Instructions
Android 4.0 and newer (Jelly Bean)
Enable the USB Debugging option under Settings > Developer options.
For Android 4.2 and newer, Developer options is hidden by default; use the following steps:
On the device, go to Settings > About .
Tap the Build number seven times to make Settings > Developer options available.
Then enable the USB Debugging option. Tip: You might also want to enable the Stay awake option, to prevent your Android device from sleeping while plugged into the USB port.
Kindle Fire devices
Select Settings > Security and set Enable ADB to On. For more information, see the Amazon documentation.
If you are running Android 4.2.2 or later, you may see the following dialog when you connect your device to your PC running RAD Studio:
Click OK to allow USB debugging on your PC. If you accidentally click Cancel, disconnect your device from your PC and connect it back to make the dialog show up again on your device.
Troubleshooting
If your Android device is not correctly detected by RAD Studio or the system Device Manager, follow the steps above to verify that USB debugging is enabled.
For general information about development setup for Android devices, see the Android documentation.
Источник
How To Enable USB Debugging Mode On Android Device
If you want to run an android app automation test using Appium on a physical Android device such as a phone or pad, you need to first enable USB debugging mode in your physical Android device and then connect it with your PC using a data line. Below are steps about how to do that.
1. Step-1: Enable Developer Options.
Below steps are the prerequisites before you can enable USB debugging mode on an android device. If you have already done this step before, then you can go to step 2 directly.
Click the Settings icon on the android OS main screen.
Scroll down in the Settings menu list, check whether there is a menu named ” Developer options ” at the bottom above the About phone menu item, if you can see that option you can type it to disable or enable it. If you can see that option, it also means you have done step-1 before, you can skip step-1 and go to step-2 directly. In my example, I can see that option because I had enabled it before.
If you can not see the ” Developer options ” menu, you should go to the ” About phone ” menu and tap it. The About phone menu is located at the bottom of the Settings menu list.
Scroll down to the ” Build number ” menu item in the ” About phone ” menu list.
You need totally tap seven times on the ” Build number ” menu item, after the first three-tap, it will popup message show you something like ” If you continue tap twice or more you will be a developer “, keep typing until you see another message like ” You are now a developer! “.
Then go back to the Settings menu list, you can see the ” Developer options ” menu item in it.
2. Step-2: Enable USB Debugging Mode.
After enabling the ” Developer options ” menu in step-1, you can enable USB debugging mode now. But what I want to remind you of is that do not make your android phone or pad in USB debugging mode always, just enable it when you needed. There are security risks in that mode because it permits high-level operation on your android device. So to make your android device ( phone or pad ) safe, you should disable this option immediately after you use it.
Type on the ” Developer options ” menu item in the Settings menu list.
Check the ” USB debugging (Debug mode when USN is connected)” checkbox to enable it.
It will prompt you to ask whether ” Allow USB debugging ” or not, click the OK button.
The detailed message of the Allow USB debugging? popup dialog is as below.
Now the USB debugging mode has been enabled completed successfully.
3. Step 3: Check Whether Device Is Connected With PC Properly.
Use a USB line to connect your android device with the PC, then you can run the below dos command to verify that the android device in USB debugging mode is connected with the PC properly.
Open dos window.
Execute command ” adb devices ” in the dos window. Then you can see the connected android devices list.
If you can not see any device, maybe it is because of a connection issue or you do not enable USB debugging mode correctly. The most possible reason is that you do not install your android device’s USB driver correctly on your PC. Below are some general android device’s USB driver provider links.
Click here to download the Samsung device USB driver, Click here to download the Lenovo device USB driver, Click here to download the HTC device USB driver. Otherwise, you can go to your phone’s manufacturer’s website to download related USB drivers.
4. Install Google USB Driver In Android SDK Manager.
If you really can not find the correct USB driver for your android device, you can install google’s default USB driver, it can be used to install some android devices.
Launch Android Studio, click the ” Tools —> Android —> SDK Manager ” menu item.
In the pop-up dialog, click Appearance & Behavior —> System Settings —> Android SDK on the left side, then click the SDK Tools tab on the right side, then check the ” Google USB Driver ” checkbox, click Apply button. Then click the Finish button in the next dialog to complete the install.
Click the Windows Start menu, input “device manager” in the windows command input box. Press Enter key.
In the Device Manager window, right-click your portable devices in the path Laptop —> Portable Devices —> Nexus 7 (your portable device).
Click the Properties menu item in the above popup menu list. It will open the detail properties dialog with the title Nexus 7 Properties. Click the Driver tab, then click the ” Update Driver… ” button.
Browse to the Google USB driver saved directory. Commonly you can find the driver in your android SDK installation directory like C:\Users\Jerry\AppData\Local\Android\sdk\extras\google\usb_driver .
After installing google provided USB driver, you can see the connected android device uses adb devices command in the command line.
Now you can run a native android app automation test in your physical android device using Appium and selenium webdriver, we will introduce that in later articles.
Источник
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 Elementon 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 Screencastto 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