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.
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.
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.
ATTR{idVendor}
property. For a list of vendor IDs, see USB Vendor IDs, below. To set up device detection on Ubuntu Linux:
/etc/udev/rules.d/51-android.rules
.SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", MODE="0666", GROUP="plugdev"
MODE
assignment specifies read/write permissions, and GROUP
defines which Unix group owns the device node.udev
documentation for your system as needed. For an overview of rule syntax, see this guide to writing udev rules.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With