Run an Android Project on your Android Phone

In this tutorial, you will learn how to run an Android application project on a physical Android device. We will perform a basic setup for your device to ensure that your Android application will be debuggable. You can use any Android device as an environment for running, debugging, and testing your applications. So lets begin…

REQUIREMENTS

  1. USB data cable for your device.
  2. Android OS(Operating System) device.
  3. Installed the appropriate driver for your Android device on your computer.

SETUP PHONE AS DEBUG MODE

Connect your USB data cable to your device. Switch on your device and Tap on Settings as shown on the screenshot below.

Tap on Settings

Now scroll down and locate Developer options in your device settings.

Select Developer Options

Tick the USB debugging checkbox.

Tick USB debugging

RUN AN ANDROID APPLICATION PROJECT 

Start Eclipse, select the project we have create on our previous post  and click Run or press Ctrl-F11. In the device chooser, select “choose a running Android device” and select your Android device as shown on the screenshot below.

Run Project on Android Phone Device Chooser

You should now see the compiled project on your Android device. By compiling and running projects on your physical Android device, you could easily interact with your own apps or do some in-depth testing or debugging.

Run Project on Android Phone

DEBUG AN ANDROID APPLICATION PROJECT

To debug your app, select the icon shown on the screenshot below or press F11 on your keyboard.

Run Project on Android Phone Debug

Choose your device on the device chooser and click OK. While starting debug mode, you should see a dialog showing “Waiting For Debugger” on your Android device.

Run Project on Android Phone Debug Mode

Lets try to debug this application, open your MainActivity.java and insert a breakpoint next to the TextView as shown on the screenshot below.

Run Project on Android Phone Breakpoint

Now tap on the button on your Android application. The breakpoint should stop the application from running pass the TextView as shown on the screenshot below.

Run Project on Android Phone Breakpoint Stop

Press F6 one at a time to see how the application runs. Use this debugging method to check for coding errors in your future application development. To resume the activity, press F8. If you encounter any errors that forces your application to close, be sure to check on the logcat view in your Eclipse.