With android studio, you can develop your application and test that application in in-built emulator. This is a great way to test and debug your application. But before releasing your application to the general user or your targeted audience, you need to test that application on a real device. This post shows you how to setup your application on hardware device through android studio running on “Ubuntu”.

Yes, it’s probably right thing to say that debugging your application on device via Windows is easy as compared to Linux. If you are debugging on Windows, all you need is to install a USB Driver for adb. For more information regarding installation of USB driver you can click here.

If you are developing on Mac, well nothing to say more, it just works fine.

If you are developing on Ubuntu, you need to make some configurations to make that happen. Following steps describe the procedure:

  • You need to add a udev file in your /etc/udev/rules.d/ folder named as 51-android.rules. In this file you need to describe some rules for adb.  This file contains USB configurations for each type of device you want to use for development.  In this file, each vendor is identified by unique ID which is specified by ATTR{id property}.
  • To create file 51-android.rules, just type following commands in your terminal.

touch 51-android.rules – This command create the file with timestamp.

sudo chmod 766 51-android.rules – This command change the permissions of the file, so that you can edit the file in future.

sudo vi 51-android.rules – This command open the file in vi. If you open the file in gedit and gives error on saving the file. Just edit the file in some other editor like notepadqq.

  • Use the following format to add each type of vendor configuration.
    • SUBSYSTEM==”usb”, ATTR{idVendor}==”22b8″, MODE=”0666″, GROUP=”plugdev”
    • Here, ATTR{idVendor} represents unique if for each vendor. For example, id 22b8 represents Motorola. You can refer this link for more vendor id’s.

After editing and saving the file, you are ready to go.

If you are using android studio, just run and debug the application. You will be presented with choose your device screen in which you can choose your connected android mobile device. Just select the device in which you want to install and you are good to go.

 

Advertisements