Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug my application in Linux with my Android mobile?

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.

like image 958
Narendra Avatar asked Dec 16 '11 07:12

Narendra


People also ask

Can I run debug APK on device?

Android Studio 3.0 and higher allow you to profile and debug APKs without having to build them from an Android Studio project. However, you need to make sure you're using an APK with debugging enabled. To start debugging an APK, click Profile or debug APK from the Android Studio Welcome screen.


1 Answers

This question is answered in the documentation for debugging against a mobile device: Using Hardware Devices.

Directly quoted from their documentation:


  1. 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.

  2. 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).

  3. 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).

  4. 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:
      1. 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.
      2. 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.

like image 196
Merlyn Morgan-Graham Avatar answered Oct 07 '22 01:10

Merlyn Morgan-Graham