I'm trying to figure out how to debug applications directly on my phone (HTC Desire).
I've installed the USB driver that came with the phone and the phone is listed when using "adb devices".
How do I configure eclipse/ADT to launch on the phone instead of launching the emulator/virtual device?
Note: This answer is a heavily modified version of this guide that used to exist at developer.android.com. Portions of it are quoted verbatim from the original text without attribution for the specific parts that are quoted.
With an Android-powered device, you can develop and debug your Android applications just as you would on the emulator.
1. Declare your application as "debuggable" in AndroidManifest.xml.
<application
android:debuggable="true"
... >
...
</application>
2. On your handset, navigate to Settings > Security and check Unknown sources
3. Go to Settings > Developer Options and check USB debugging
Note that if Developer Options is invisible you will need to navigate to Settings > About Phone and tap on Build number several times until you are notified that it has been unlocked.
4. Set up your system to detect your device.
Follow the instructions below for your OS:
Windows Users
Install the Google USB Driver from the ADT SDK Manager
(Support for: ADP1, ADP2, Verizon Droid, Nexus One, Nexus S).
For devices not listed above, install an OEM driver for your device
Mac OS X
Your device should automatically work; Go to the next step
Ubuntu Linux
Add a udev rules file that contains a USB configuration for each type of device you want to use for development. In the rules file, each device manufacturer is identified by a unique vendor ID, as specified by the ATTR{idVendor} property. For a list of vendor IDs, click here. To set up device detection on Ubuntu Linux:
Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
Use this format to add each vendor to the file:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node.
Now execute: chmod a+r /etc/udev/rules.d/51-android.rules
Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.
5. Run the project with your connected device.
With Eclipse/ADT: run or debug your application as usual. You will be presented with a Device Chooser dialog that lists the available emulator(s) and connected device(s).
With ADB: issue commands with the -d flag to target your connected device.
Sometimes you need to reset ADB.
To do that, in Eclipse, go:
Window>>
Show View >>
Android
(Might be found in the "Other" option)>>Devices
in the device Tab, click the down arrow, and choose reset adb.
in devices which has Android 4.3 and above you should follow these steps:
How to enable Developer Options:
Launch Settings menu.
Find the open the ‘About Device’ menu.
Scroll down to ‘Build Number’.
Next, tap on the ‘build number’ section seven times.
After the seventh tap you will be told that you are now a developer.
Go back to Settings menu and the Developer Options menu will now be displayed.
In order to enable the USB Debugging you will simply need to open Developer Options, scroll down and tick the box that says ‘USB Debugging’. That’s it.
Related
I used Unity 2019.
When I connect my android devices (3 devices, tablet included) to Unity and try to run and build any apk, devices are recongized in Unity but the compilation process fails. lt's, writtren :Android device 52000... is not responding
I had this problem with my new phone, which was occurring even after enabling USB debugging and authorizing the PC through the phone. I ended up finding the answer in here Unity's documentation:
Run the adb devices command from the platform-tools directory of your
Android SDK installation and check the output.
If the output list is empty and you are using Windows, you may need to
install the driver for ADB devices. For more details, refer to the
Android SDK/NDK Setup documentation.
If the list contains entries with the unauthorized label, you may need
to authorize your computer on your device and give it permission to
debug it. Check the device’s screen for the corresponding dialog.
If the list contains your device with the device label, build your
Project in Unity again.
I resolve the problem.
In USB connection mode, on my phone, there are 4 options:
Transfer files
transfer images
Connect a MIDI device
Charge this phone.
I ONLY changed the connection mode to TRANSFER IMAGES.
After that, I received a prompt asking me the validate this connection mode. I did it and it works fine.
I resolved this issue, by changing the USB connection mode to Image Transfer(PTP) in my MI device
the problem is very clear. The compilation is successful, which means there is nothing wrong with your code. And the error message in the dialog box is clearly saying that
Make sure USB debugging has been enabled
So, to solve this simply follow the steps below -
Navigate to Settings > About Phone > Scroll to bottom > Tap Build number several times
Go back and now access the Developer options menu, check 'USB debugging' and click 'OK' on the prompt
You can also checkout this link
On android device, when prompted for "Allow USB debugging?", selecting "Always allow from this computer" checkbox solved the problem for me.
In order for my phone to show up the "Allow USB debugging?" dialog, I revoked the USB debugging authorisations from my android device and then ran "adb devices".
Also once I did this, unity was showing my device name instead of just device id.
Here's what worked for me.
Windows key type cmd
cd C:\Users\[name]\AppData\Local\Android\Sdk\platform-tools
adb kill-server
adb start-server
New to Android development, I've made a small app using Eclipse that works perfectly on a virtual Android device. Now, I want to run it on the real device: Moverio, a head-mounted display made by Epson, but my computer just does not recognize it as an Android device.
Being on Windows 7, I understood I need a specific USB driver. Epson sent me instructions to install the driver, but it still doesn't work. How can I do it?
Here are the steps I followed:
Add following two lines in [Google.NTx86] and [Google.NTamd64] sections in
\extras\google\usb_driver\android_winusb.inf:
%SingleAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04
%CompositeAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04&MI_01
Add vendor ID in [username].android\adb_usb.ini]
Enable USB debugging mode on the device
Install USB driver following instructions given here http://developer.android.com/tools/extras/oem-usb.html#InstallingDriver
I ran into a problem in the fourth step: in my device management panel, Moverio is in the "Disk drives" category. When I right click on it to install or update drivers nevertheless, inputting the <sdk>\extras\google\usb_driver\ folder, it says the driver is up to date.
When I try to run the app using Eclipse, it asks me to install a virtual device, because it can't find any real device connected.
I managed to find a blog post walking through the process needed to enable ADB access to the device. The original is in Japanese and the Google translation left something to be desired.
I'm providing my recreation of the process below; this is partially a translation and partially an expansion and combination of the original with the official documentation which failed to cover the problem encountered with the Moverio.
With a few modifications noted at the end, I suspect this should work for installing debug support on other devices that only identify as external data drives by default as well.
The first thing you need to do is to edit the .inf file for the Google USB driver.
The file is located at \android-sdk\extras\google\usb_driver\android_winusb.inf.
By default, the android-sdk folder is located under C:\User\YourUserName\AppData\Local\Android\.
You need to add the following lines to the end of the file:
[Google.NTamd64]
; BT-100
%SingleAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04
%CompositeAdbInterface% = USB_Install, USB\VID_04B8&PID_0C04&MI_01
Next connect the device with developer mode disabled. Windows will identify it as a USB mass storage device (MSC).
You need to go into Device Manager and uninstall it. If you have multiple USB-MSDs listed under USB Serial Bus Controllers, you can identify which one is the Moverio by disconnecting it, right clicking on each one that is still present, selecting properties and noting the location value on the general tab. Then reconnect the Moverio and look for the new entry it adds.
After you've uninstalled the Moverio's USB Mass Storage Device entry, disconnect it and enable Developer mode on the device.
Then reconnect it. Device Manager will update to show a BT1 entry under Other Devices
Right click on the BT1 entry, select Update Driver Software, mrowse My Computer for driver software. Provide the path to the USB driver folder from step one. Click Next.
At this point I get a warning about not being able to verify the publisher of the driver. I believe this is related to my having edited the .inf file. Click install this driver software anyway.
Windows will report that the driver is successfully installed. Close the update dialog. You should now see an Android Composite ADB Interface entry in device manager. On my computer it's appearing under ASUS Android Devices; which I assume is a legacy of the Transformerpad I've connected in the past; in the blog I'm using as a source it appeared under Android Phone.
ADB still needs to be informed that the device is available however. To do this, you need to edit the \.Android\adb_usb.ini file. Default location of C:\User\YourUserName\ by appending the vendor ID as a new line to the end. This is an autogenerated file; but running the update process in the comment will remove the entry we need. If you unexpectedly lose the ability to debug, this would probably be a good spot to recheck.
# ANDROID 3RD PARTY USB VENDOR ID LIST - DO NOT EDIT.
# USE 'android update adb' TO GENERATE.
# 1 USB VENDOR ID PER LINE.
0x04B8
The only thing left is to stop and restart ADB. To do this, open a command prompt at \android-sdk\platform-tools. Issue the command adb kill-server followed by the command adb devices.
C:\Users\Neelyd\AppData\Local\Android\android-sdk\platform-tools>adb kill-server
C:\Users\Neelyd\AppData\Local\Android\android-sdk\platform-tools>adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
WS000 device
When ADB restarts the device should be listed, and appear in DDMS in Eclipse.
To use this procedure to install the generic Android USB driver on a different device I think all you should need to do is to right click on the device's USB Mass Storage Device entry in device manager (step 3); select details, select the Hardware Ids property, note the values displayed, and use them in place of the Moverio's in the android_winusb.inf file (step 1), and the vendor ID in adb_usb.ini (step 10).
Possible simpler option
After figuring this out, I finally got a reply from Epson support. They said it should be possible to install their driver to the USB-MSD identified in step 2 directly. If that works it would replace steps 3-6. I haven't tested it though, so I'm only leaving this note as a postscript.
Installing drivers for Windows might be much more difficult than it seems. From my experience, you have much better chance for successful development for Android on any Linux platform, be it installed next to your Windows installation on your PC or run in a virtual box. Linux does recognise almost any Android device and allows access without any driver installation.
How can I debug my Android application in a mobile, not in the emulator?
My OS is Linux. When I try to connect with my mobile device for debugging, it is not
responding.
This question is answered in the documentation for debugging against a mobile
device: Using Hardware Devices.
Directly quoted from their documentation:
Declare your application as "debuggable" in your Android Manifest.
In Eclipse, you can do this from the Application tab when viewing the Manifest (on the right side, set Debuggable to true). Otherwise, in the AndroidManifest.xml file, add android:debuggable="true" to the <application> element.
Set up your device to allow installation of non-Market applications.
On the device, go to Settings > Applications and enable Unknown sources (on an Android 4.0 device, the setting is located in Settings > Security).
Turn on "USB Debugging" on your device.
On the device, go to Settings > Applications > Development and enable USB debugging (on an Android 4.0 device, the setting is located in Settings > Developer options).
Set up your system to detect your device.
<snip - Not using Windows or Mac OS X>
If you're developing on Ubuntu Linux, you need to add a udev rules file that contains a USB configuration for each type of device you want to use for development. In the rules file, each device manufacturer is identified by a unique vendor ID, as specified by the ATTR{idVendor} property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device detection on Ubuntu Linux:
Log in as root and create this file: /etc/udev/rules.d/51-android.rules.
Use this format to add each vendor to the file:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node.
Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.
Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules
You can verify that your device is connected by executing adb devices from your SDK platform-tools/ directory. If connected, you'll see the device name listed as a "device."
If using Eclipse, run or debug your application as usual. You will be presented with a Device Chooser dialog that lists the available emulator(s) and connected device(s). Select the device upon which you want to install and run the application.
If using the Android Debug Bridge (ADB), you can issue commands with the -d flag to target your connected device.
Setting up a Device for Development
Set up your device to allow installation of non-Market applications.
On the device, go to Settings > Applications and enable Unknown sources (on an Android 4.0 device, the setting is located in Settings > Security).
Turn on "USB Debugging".
On the device, go to Settings > Applications > Development and enable USB debugging (on an Android 4.0 device, the setting is located in Settings > Developer options).
Set up your system to detect your device.
If you're developing on Ubuntu Linux, you need to add a udev rules file that contains a USB configuration for each type of device you want to use for development. In the rules file, each device manufacturer is identified by a unique vendor ID, as specified by the ATTR{idVendor} property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device detection on Ubuntu Linux:
Log in as root and create the file /etc/udev/rules.d/51-android.rules.
Use this format to add each vendor to the file:
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
In this example, the vendor ID is for HTC. The MODE assignment specifies read/write permissions, and GROUP defines which Unix group owns the device node.
Note: The rule syntax may vary slightly depending on your environment. Consult the udev documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.
Now execute:
chmod a+r /etc/udev/rules.d/51-android.rules
On Android 4.2 and newer, Developer options is hidden by default. To make it available, go to Settings > About phone and tap Build number seven times. Return to the previous screen to find Developer options.
What do I need to do to use my Kindle Fire for android development? (Specifically for testing my apps on the device.)
You can find the instructions for connecting Kindle Fire to the ADB in a PDF of instructions provided by Amazon.
Paraphrased from the document:
Edit the adb_usb.ini file (located in ~/.android/)
Add the lines:
0x1949
0x0006
Save the file.
Run these commands to restart adb:
adb kill-server
adb start-server
adb devices
NOTE: For Windows 7 users you need to download an additional driver.
Linux uses a different way to set up the device. According to Using Hardware Devices, you need to set up your Linux system as follows:
Edit /etc/udev/rules.d/51-android.rules as root, and add the following line (create this file if it does not exist):
SUBSYSTEM=="usb", ATTR{idVendor}=="1949", MODE="0666"
Change the permission of this file by executing the following command as root:
chmod a+r /etc/udev/rules.d/51-android.rules
Reload the rules by executing the following command as root:
udevadm control --reload-rules
Run these commands to restart adb:
adb kill-server
adb devices
If everything is ok, you will see your Kindle Fire listed as a device.
I was also looking forward how to connect Kindle on the ADB, so what I had to do is:
Go to Settings->Security and Enable ADB.
I use a Mac, this probably works similarly from a Windows box.
First I configured the Kindle Fire to allow sideloaded apps. This isn't the default behavior, you have to click a checkbox in the settings.
From the Fire, I went to the app store and downloaded a DropBox app (free.)
From my dev machine, I registered on the DropBox website (also free.)
This gives you a dropbox folder on your dev box that will be synced automagically to your dropbox folder on the web.
Then, to develop, I compile the app to make a new apk, drag it to the dropbox folder, and use the DropBox app on the Fire fetch the apk file. It loads with the click of a button. It takes about 15 seconds tops to get the apk to the Fire. I don't need any extra cables, etc.
You must add a user defined site in Android SDK Manager:
Launch Android SDK Manager >> Tools >> Manager Add-on Site >> User
defined>> add http://kindle-sdk.s3.amazonaws.com/addon.xml
Then download the Amazon Kindle drivers from Android SDK Manager
Then then enable ADB from kindle settings.
Settings >> Device >> Enable ADB
And run \extras\amazon\kindle_fire_usb_driver, run KindleDrivers.exe
More info
Follow the PDF
In eclipse go to android SDK manager, select Tools -> Manage Add-on Sites -> select User Defined sites.
Select New and add the url as http://kindle-sdk.s3.amazonaws.com/addon.xml.
After adding that go to packages->Extras
Download Kindle Fire USB Driver.
Go to android SDK folder->amazon->install the drivers.
Last step: You can see the device at In Device Manager, under Kindle Fire, verify that the device appears as Android Composite ADB Interface.
I made an Android Hello world app and I'm trying to load it onto my HTC Incredible. I believe it has 2.2 (how do I confirm that?)
Anyway, Eclipse gives me this message and then brings up the window in the screenshot below.
Automatic Target Mode: Unable to
detect device compatibility. Please
select a target device.
I'm on Ubuntu 64bit if that matters. I did turn on USB debugging on the phone. I told the phone to connect as a disk drive.
Any ideas how to get my app onto the phone?
Update: Do I need to perform these steps since I'm on Ubuntu? I doesn't mention what to do for Ubuntu 8.10 though.
Ok, it turns out I did have to follow all the instructions from this page. (The sudo stuff mentioned in other answers above didn't help.)
Here are the exact commands I ran for Ubuntu 8.10
You need to run the adb server in superuser mode (i.e. sudo adb start-server).
Try what EboMike said, run sudu adb start-server.
To answer your question "how do I confirm my phone is V2.2?" Press your phone's menu key, then settings, about phone, software information. The Android version is the number you're looking for. This shouldn't be important though for your hello world example.
Also, it's not important that you have the phone connect as a disk drive; this causes the SD card to be dismounted. It will actually cause problems if you run or debug an application that tries to access the SD card. You can just select charge only and use ADB/Eclipse's DDMS perspective to move files to and from the phone.
Here's an update answer in case anyone finds this thread from Google.
http://dimitar.me/how-to-connect-your-android-phone-to-ubuntu-to-do-developmenttestinginstallations-or-tethering/
The easiest way to this: Go to www.dropbox.com and sign up for a free account. Copy your .apk file from your project's /bin directory to your Dropbox. Download and install the free Dropbox app from the Android Market. Navigate to your .apk file on the Dropbox app and click it to download and install on your phone.
These are the steps I took on Arch Linux to resolve the same problem:
As mentioned in some of the other replies you will need a udev rule for the device. In this example I am using an HTC Desire.
(for HTC you'll need to use "0bb4")
Get the correct Vendor and Product IDs
run lsusb with the handset plugged in and you should see something like Bus 001 Device 004: ID 0bb4:0c87 High Tech Computer Corp. Desire (debug)
'0bb4' is the Vender ID: HTC
'0c87' is the Product ID
Make a udev rule using the values you've just retrieved
Now make a udev rule as root using:
$ sudo vim /etc/udev/rules.d/51-android.rules
Add the following (this is for HTC Desire - edit accordingly):
## Rule for an HTC Desire Android Phone
SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0c87", MODE="0666", GROUP="users", NAME="HTC Desire"
GROUP defines which Unix group owns the device node.
At this point I rebooted and found that my handset was detected. Supposedly you can reload udev rules using the following but if this doesn't work try rebooting.
$ sudo udevadm control --reload-rules
in eclipse: go to Run menu -> Run configuration. Right click on android application on the right side and click new. Fill the corresponding details like project name under the android tab. Then under the target tab. Select launch on all compatible devices and then select active devices from the drop down list. Save the configuration and run it by either clicking run on the run button on the bottom right side of the window or close the window and run again
Cheers !