How-to-debug-Qt-applications-on-Android-device: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
(Convert ExpressionEngine links)
mNo edit summary
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
[[Category:HowTo]]
[[Category:HowTo]]


Line 6: Line 4:
I will show you how to achive this for Samsung device, but the same steps are required for any android device, you just have to know who is a vendor of your device.
I will show you how to achive this for Samsung device, but the same steps are required for any android device, you just have to know who is a vendor of your device.


You might also need to put the device in "developer mode", that is, enable "USB debugging" in the Settings>Developer Options of the device.
You might also need to put the device in "developer mode", that is, enable "USB debugging" in the Settings Developer Options of the device.


See also [http://developer.android.com/tools/device.html Using Hardware Devices] .
See also [http://developer.android.com/tools/device.html Using Hardware Devices] .


Steps to achieve this are as follows:
Steps to achieve this are as follows:
1. Run lsusb | grep Samsung (if you use let’s say HTC device just type HTC instead of Samsung after “grep”). You will see something like this:
1. Run
<code>Bus 001 Device 003: ID 04e8:689e Samsung Electronics Co., Ltd GT-S5670 [Galaxy Fit]<code>
 
<code>
lsusb | grep Samsung
</code>
 
if you use let’s say HTC device just type HTC instead of Samsung after “grep”. You will see something like this:
 
<code>
Bus 001 Device 003: ID 04e8:689e Samsung Electronics Co., Ltd GT-S5670 [Galaxy Fit]
</code>
 
Strings 04e8 and 689e are of a key value to get your android device propely recognized.
Strings 04e8 and 689e are of a key value to get your android device propely recognized.


Line 18: Line 26:


3. In the file 51-android.rules input this:
3. In the file 51-android.rules input this:
</code>SUBSYSTEMS”usb”, ATTRS{idVendor}”04e8″, ATTRS{idProduct}==“689e”, MODE=”0666″</code>
 
<code>
SUBSYSTEMS”usb”, ATTRS{idVendor}”04e8″, ATTRS{idProduct}==“689e”, MODE=”0666″
</code>
 
If you take a closer look you will see that we used those bold numbers from step 2 so that we can make our rule apply only to our device. So the first string04e8 is an ID of a vendor of the device (in this case vendor is Samsung), and the second string 689e is the ID of the product (in this case product is a GT-S5670 which is a designation of Samsung Galaxy Ace mobile device). MODE=“0666” just tells that the node that udev will create should be readable and writable by everyone.
If you take a closer look you will see that we used those bold numbers from step 2 so that we can make our rule apply only to our device. So the first string04e8 is an ID of a vendor of the device (in this case vendor is Samsung), and the second string 689e is the ID of the product (in this case product is a GT-S5670 which is a designation of Samsung Galaxy Ace mobile device). MODE=“0666” just tells that the node that udev will create should be readable and writable by everyone.


4. After you have saved the file, run this command in order to reload udev’s rules: <code>udevadm control —reload-rules<code>
4. After you have saved the file, run this command in order to reload udev’s rules: <code>udevadm control —reload-rules</code>


5. After you have reloaded the udev’s rules, you need to restart adb. Go to the folder where you keep your android SDK. Go to the folder platform-tools inside the android SDK directory and run:
5. After you have reloaded the udev’s rules, you need to restart adb. Go to the folder where you keep your android SDK. Go to the folder platform-tools inside the android SDK directory and run:
</code>adb kill-server</code>
 
<code>
adb kill-server
</code>
 
and after that
and after that
<code>adb start-server <code>


NOTE: if you get command not recognized error, just run those commands like this:
<code>
</code>./adb kill-server</code>
adb start-server
and
</code>
<code>./adb start-server<code>
 
NOTE: make sure that adb is in your PATH.


This will reload adb server and it should now list your device, just run adb devices and if you see something like this:
This will reload adb server and it should now list your device, just run adb devices and if you see something like this:
</code>List of devices attached
 
<code>
List of devices attached
S5830cba628dc device
S5830cba628dc device
<code>
</code>
 
After this your device is properly recognized.
After this your device is properly recognized.
Now you are set and ready. Next time you hit Run button in Qt-Creator your app will load on your mobile device.
Now you are set and ready. Next time you hit Run button in Qt-Creator your app will load on your mobile device.

Revision as of 15:02, 31 March 2015


This is a guide on how to enable a real on-device debugging for Qt applications on Android under Linux. I will show you how to achive this for Samsung device, but the same steps are required for any android device, you just have to know who is a vendor of your device.

You might also need to put the device in "developer mode", that is, enable "USB debugging" in the Settings → Developer Options of the device.

See also Using Hardware Devices .

Steps to achieve this are as follows: 1. Run

lsusb | grep Samsung

if you use let’s say HTC device just type HTC instead of Samsung after “grep”. You will see something like this:

Bus 001 Device 003: ID 04e8:689e Samsung Electronics Co., Ltd GT-S5670 [Galaxy Fit]

Strings 04e8 and 689e are of a key value to get your android device propely recognized.

2. Now make a rule 51-android.rules in the /etc/udev/rules.d/ directory. The number 51 is an information to udev so it can know in which order to load the rules. You can type some other number if you already had some rules defined, but keep in mind the order in which those rules will be applied.

3. In the file 51-android.rules input this:

SUBSYSTEMSusb, ATTRS{idVendor}04e8, ATTRS{idProduct}==689e, MODE=0666

If you take a closer look you will see that we used those bold numbers from step 2 so that we can make our rule apply only to our device. So the first string04e8 is an ID of a vendor of the device (in this case vendor is Samsung), and the second string 689e is the ID of the product (in this case product is a GT-S5670 which is a designation of Samsung Galaxy Ace mobile device). MODE=“0666” just tells that the node that udev will create should be readable and writable by everyone.

4. After you have saved the file, run this command in order to reload udev’s rules:

udevadm control reload-rules

5. After you have reloaded the udev’s rules, you need to restart adb. Go to the folder where you keep your android SDK. Go to the folder platform-tools inside the android SDK directory and run:

adb kill-server

and after that

adb start-server

NOTE: make sure that adb is in your PATH.

This will reload adb server and it should now list your device, just run adb devices and if you see something like this:

List of devices attached
S5830cba628dc device

After this your device is properly recognized. Now you are set and ready. Next time you hit Run button in Qt-Creator your app will load on your mobile device.