Android debugging on real device

This tutorial will show you how to debug Android application on a real Android-powered device (mobile phone).

Tools and environment in this tutorial :

  1. Eclipse IDE 3.7 + ADT Plugin
  2. Samsung Galaxy S2
  3. Windows 7

Summary steps to debug on device :

  1. Download Google USB Driver (if using Android Developer Phones (ADP))
  2. Download OEM USB Drivers (if using other Android-powered device, Samsung, Acer, HTC…)
  3. In your device, turn on USB debugging.
  4. Connect your device to the PC.
  5. Use “adb devices” to verify that your device is connected successfully.
  6. Change Eclipse “Deployment Target Selection Mode” to “Manual”, and select the device at runtime.
  7. Done.

In this example, we will use the previous “Hello World Android Example“, and debug or run on a real Android-powered device, Samsung Galaxy S2.

1. Download OEM USB Driver

Refer to this Android USB driver guide. If you are using Android Developer Phones (ADP) like Nexus One or a Nexus S, you should install the Google USB driver via “Android SDK Manager“.

With Samsung Galaxy S2, you need to install OEM USB driver, or Samsung USB driver, which included in the Samsung Kies software.

Refer to this “where to download Samsung Galaxy S2 USB driver” guide to get USB driver install on your PC.

get samsung USB driver

2. Enable USB Debugging

In your device, to turn on USB debugging : “Settings” -> “Applications” -> “Development” -> “USB debugging”.

See figure below :

enable usb debugging on Android

3. Connect device to PC

Connect Samsung Galaxy S2 to the PC, and verify it via command “adb devices“.

In commmand prompt, change path to “Android SDK/platform-tools“, type command “adb devices“, if you see something like “some-weird-number device“, it means your device is connected to PC successfully.

Figure – The “304D19665059DF6E device” is the Samsung Galaxy S2.

adb devices

4. Eclipse -> Android

Note
Most people are stuck in this stage, beware.

Previously, you may created few “Android Virtual Devices (AVD)” for testing, and set “Deployment Target Selection Mode” to “Automatically“, however, this will caused the application failed to debug on your connected device and keep starting the AVD emulator.

2 solutions :

  1. In Eclipse right click on Android project, select “Run” -> “Run Configuration” -> “Android Application” -> “Target” tab -> “Deployment Target Selection Mode” -> set it to “Manual“, and you can select the device at runtime.
  2. Alternative, in “Deployment Target Selection Mode“, just deselect all the selected AVD.

Figure : Deployment Target Selection Mode

android eclipse deployment target

Figure : Select your device at runtime

select device at runtime

5. Start It

In Eclipse, run or debug your project as Android project, select your device at runtime and the project will copy to your Samsung Galaxy S2 and started automatically.

Figure : HelloWorldApp debugging on Samsung galaxy S2.

android hello world
android hello world

References

  1. Android developing on real device
  2. Android OEM USB driver
  3. Android debug on Samsung Galaxy S2
  4. Android hello world example

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

Leave a Reply

avatar
newest oldest most voted
Hossein Badrnezhad
Guest
Hossein Badrnezhad

thanks <3

Nitish Sharma
Guest
Nitish Sharma

how to access web service from real device . my real device and server is on same network (Wi-fi).

Sanjay Dubey
Guest
Sanjay Dubey

Thanks, that’s work well.

Sunny
Guest
Sunny

Thanks a ton. This just worked. Although shamelessly I have read through your post and used the ideam and never cared to comment or like your post, but this time I couldn’t stop my excitement when it just worked 1st time itself following your steps. Thanks again.

mfara012
Guest
mfara012

Thanx a lot very straight forward

Raghavendra
Guest
Raghavendra

Simply great work

JF Gagnon
Guest
JF Gagnon

Sometimes it works but usually all my breakpoints are skipped. It drive me nuts.

Kevin
Guest
Kevin

When you finally get the numbers, you are able to communicate and get
a particular idea about their services and the rates.
The brick tiles which the website stocks are extremely helpful in kitchen areas and also provide a very good brickwork effects.
It is present everywhere, because a simple search internet based will most
likely give many, numerous results. yet another form of
stone for paving is actually the interlocking pavers what kind of
since the name suggests tend to be connected in these a way that each rock restricts the different from moving.

Leelavathy
Guest
Leelavathy

Iam using samsung galaxy W. When i try to look into the list of running applications in DDMS perspective to start method debugging the process list doesnt show up. Any suggestions are welcomed.

Thankyou

Ramachandran
Guest
Ramachandran

How to connect with out using usb cable.

Mahbub Siddique
Guest
Mahbub Siddique

this is very helpful tutorial.Thanks a lot for your post…….

Mona
Guest
Mona

Omg, this is awesome! So well-documented & thorough! Thanks a bunch!

eye drops for dogs
Guest
eye drops for dogs

Is truly water tank conveniently accessible and not cramped for pouring
water at? is actually the pot alone very easy to slip
at and from the unit? Will the coffee basket get rid of easily?
are really the areas that require exclusive casual
scrubbing very easy to go? . whenever living in Spain I have inside consuming
coffee making use of a powerful stove espresso maker because these appeared
to be almost all anyone ever familiar with render coffee now whenever we
returned to the united kingdom I bought myself any.

Andrey
Guest
Andrey

Is it noticeable faster to debug on a real device than on an emulator?

Adrian Mikeliunas
Guest
Adrian Mikeliunas

Yes, is faster because you are not killing your RAM and CPU with the emulator…

trackback
Android Device Drivers: not found? : Android Community - For Application Development

[…] Android debugging on real device […]

Srinu
Guest
Srinu

Great Tutorial.Thank you….

rasty
Guest
rasty

Brilliant Gracias!!

tommy
Guest
tommy

Thank you so much, now I am able to connect samsung galaxy ace plus and do development.

Mirko Ugolini
Guest
Mirko Ugolini

Great tutorials
Thanks

Ali
Guest
Ali

For me everything works fine and Eclipse does show me that application has been installed but it does not launch that application and when i check my phone there is no app installed in the app area but when i go to “Manage Application” I can see my app installed. Its really annoying scenario and i really need help urgently. Thanks

PS. I am using Galaxy Note.

arsalan ali
Guest
arsalan ali

thanku soo much ..:)

trackback
Android hello world example
[…] Press “Home” button (on right hand side), and you will noticed that “HelloWorld” application is deployed successfully on the Android virtual device. Note This tutorial is more to example driven, not much explanation. For detail and complete explanation, please refer to the official Android developer hello world tutorial. Firewall… In my computer, the COMODO firewall is installed and blocked the deploying process, caused the connection between Eclipse ADT and AVD is blocked and failed to deploy. Just make sure your firewall is configured properly, or just turn it off for Android development :) Debug Android application on real device… Read more »
khushbu
Guest
khushbu

thanks a ton !!!

Carlton
Guest
Carlton

Thanks, perfect

Fernando
Guest
Fernando

Great, now testing in s2 :) Thanks

Jørgen
Guest
Jørgen

‘Android debugging on real device’

Excelent tutorial, just what I needed :-)

/Jørgen

trackback
Cheatsheet: 2012 03.13 ~ 03.22 - gOODiDEA.NET

[…] Android debugging on real device […]

trackback
Cómo depurar una aplicación Android en un dispositivo « Java Mania

[…] este post nos muestra cómo depurar una aplicación Android en un dispositivo […]