QT android + remote debugging - android

I've been trying to setup ADB remote debugging for Qt.
Scenario:
Remote development server with QT
Local laptop with connected phone
Solution:
I tunnel all the traffic on port 5037 (default adb port) through a Remote Port Forwarding SSH session. Works Fine.
The commands I execute:
# Kill old adb server.
devhost$ adb kill-server
# Activate adb server on client
laptop$ adb start-server
# Start ssh tunnel. Hide/minimize this window not to close it by accident
laptop$ ssh -XC -R 5037:localhost:5037 <your devhost machine>
QT on dev. server detects the mobile, attempts to the deploy.
The app gets deployed. The result FEELS GOOD. ~~With dev server in another country. It's optic fiber all the way from server right to my desk... But not so fast...
When all of the sudden QT shouts about being unable to connect with localhost:5039
5039? What is it needed for? I tried tunelling 5039 but I'm basically in a blind-spot. The error is gone but the app is stuck at waiting for debugger and no further messages from QT no errors.
Nothing. It just hangs indefinitely.
On the mobile there's the standard waiting for debugger msg at the bottom. (Note: the app got deployed by qt and launched).
Ideas?
The only informative message within log is:
W ActivityThread: Application org.qtproject.APPNAME is waiting for the debugger on port 8100...
8100? now what is that? Is that supposed to be taken care of by ADB/QT or what
I can see all the logcat events on dev-server while the app on mobile 'keeps waiting' ..browser entire logcat log. the only sensible message regarding debugging is that the app keeps waiting on and on.
Local debugging of same app through USB works FINE.
The remote server is able to compile deplay and launch the app on mobile phone, however dubugging is an exercise in futility due to the described behaviour.
I have noticed that during debugging attempts, adb on local laptop keeps opening new ports and listening on these. what the heck is going on here?
On the contrary, when debugging over USB, 5037 is the only port used everything works and adb does not go into the new-port-creation frenzy.

Related

telnet on hosted machine running on azure devops pipeline

Here is my detail about my problem:
what I want to achieve:
create a pipeline on azure DevOps, containing tasks
create android emulator with internet condition full
run some tests
connect telnet
connect telnet to android console port- send command to android device to change nework condition to low bandwidth as mentioned here (https://developer.android.com/studio/run/emulator-console)
Note: I have hosted MacOS, also telnet+expect and spawn is installed over it
What is the problem:
My android device is running over 5037 port
telnet task output showing me "telnet connected to local host" command I am using to connect to android console port is : telnet localhost 5037 (in a command line task)
escape character is "^]"
**
it is not showing me any authentication required message or OK so I can go ahead with it, also I am trying to send command like expect"^]" returning me nothing
**
I want to run emulator -netspeed gsm #Pixel_API_26 please help

Debugging a native application with GDB on Android

I have a native C++ app which is supposed to run on an Android device. The application crashes at the startup, most likely when calling a function from a linked library. I am trying to debug it with gdb, but I can't succeed.
I am starting gdbserver on the Android device on some arbitrarily picked port (2000):
shell#msm8996: gdbserver :2000 my_app
Process my_app created; pid = 3420
Listening on port 2000
Now I am trying to attach to this process on my Host system (Windows 7) with gdb that was provided in Android-NDK.
C:\> gdb
(gdb) attach 3420
Can't attach to process.
(gdb) target remote :2000
:2000: The system tried to join a drive to a directory on a joined drive.
What is the problem?
EDIT:
Prior to running gdb I forwarded the port 2000 using adb:
adb forward tcp:2000 tcp:2000
This at least helped me to establish some communication, but:
(gdb) target remote :2000
Remote debugging using :2000
warning: Architecture rejected target-supplied description
Remote 'g' packet reply is too long: 00000000000000000000000000000...
On the device side:
Listening on port 2000
Remote debugging from host 127.0.0.1
readchar: Got EOF
Remote side has terminated connection. GDBserver will reopen the connection.
Listening on port 2000
You are most probably using different architecture / version of gdb. When you start the gdb, it displays a line like (I am showing what my GDB shows):
This GDB was configured as "--host=x86_64-linux-gnu
--target=arm-Linux-android"
Check if this matches with your phone's architecture.
Downloading the correct GDB version may solve your problem.

Android ADB port number changes, Eclipse can't connect to devices

I upgraded to a new pc using Windows 7. Eclipse can't connect to the ADB. Ever. Task Manager shows the ADB port number to be anywhere from 3180 to 5452, never in the range 5555 to 5585 it should be at. Going to the command prompt entering "kill-server" then "start-server" to reset last showed "daemon not running. starting it now on port 5037 * daemon started successfully" but the next command "adb devices" shows nothing attached. The port number changes and DDMS shows the ADB was forcefully closed so there's a connection somewhere.
I tried updating drivers and forcing the port number connection using 'adb port xxxx' but obviously it hasn't worked or I wouldn't be posting here. With my last pc using WinXP I was able to force the port number if needed to make it work but that isn't happening here.
Any suggestions?

How to know the console port number of Android Emulator to which it is bound?

I need to know, how I get console port to which android emulator is connected programmatically. I am using library com.android.ddmlib.
To be more specific: Let's say that I have already started some emulator and when I execute some program, it checks if there is some emulator on some port (e.g. 5554). If it is, the output is true, otherwise false.
I can access all devices (IDevice) from android debug bridge, but I am not able to realize, if that particular device is bound to some specific port.
All I see is the output from adb devices -l, but it writes only "emulator-5554". Is it the only way how to realize the port?
The command adb start-server shows the message,
* daemon not running. starting it now on port xxxx *
"xxxx" is the port number which is being used by adb.

Intermittent problems deploying and debugging android app to phone

I am currently investigating a problem I have where for some reason eclipse plugin/adb loses connection to my phone and gives me the message:
[2011-03-05 22:53:40 - projectOne] Attempting to connect debugger to 'com.testbed.input' on port 8633
[2011-03-05 23:04:02 - projectOne] ------------------------------
[2011-03-05 22:40:42 - projectOne] Android Launch!
[2011-03-05 22:40:42 - projectOne] adb is running normally.
[2011-03-05 22:40:42 - projectOne] Performing com.testbed.input.MainActivity activity launch
[2011-03-05 22:40:42 - projectOne] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
And on the device monitor log I see this:
[2011-03-05 23:10:13 - Logcat]device (HT971L900496) request rejected: device offline
java.io.IOException: device (HT971L900496) request rejected: device offline
I cant figure out what it is, it just works flawless one day and next I get this. I hope someone with a more expert knowledge of the tool chain can help as its really slowing me down so I am determined to get to the bottom of this.
Many thanks
I can confirm that intermittent "adb devices" problems can be put down to using the wrong USB port.
I think it has something to do with the power output of the various ports (i.e. not enough power).
I had intermittent problems with USB connection to Android Note II (Samsung Note 2 clone) for a week.
I didn't believe all the Google articles saying to use a different USB socket,
because I didn't think I had any others than the two on the front right of my Lenovo Thinkpad L420.
Guess what, after finally checking the back carefully, there it is, a single USB socket on the very end.
After plugging into that socket, "adb devices" always lists the device.
Hooray!
For the benefit of other (Ubuntu) users, I am showing my tips for getting "adb devices" to work.
Figure out how the device is recognized by Ubuntu Linux.
Plug in the device, do "lsusb" then use the first hex number of the device ("0bb4" here)
as the "idVendor" attribute in a file called, "/etc/udev/rules.d/99-android.rules",
with the following, one-line contents:
SUBSYSTEM=="usb",ATTR{idVendor}=="0bb4",MODE="0666",GROUP="plugdev"
** Do not put spaces after the commas in this line.
Then, "sudo service udev restart".
Don't forget to add yourself to the "plugdev" group: "sudo usermod -aG plugdev".
Execute: adb kill-server; adb start-server; adb devices.
The adb server listens on port 127.0.0.1:5037 (netstat -anp|grep LISTEN).
So if any adb command is hanging, check that you can "ping 127.0.0.1".
If localhost ping fails, check firewalls and also check "sudo iptables-save",
looking for a missing "allow" rule for localhost ("lo").
Also, "ifconfig -a" will expose whether localhost interface is up (Google "ifup").
I hope someone else finds this information useful.
I don't know why it happens but I have found a quick remedy - first kill any adb process.
Then start the adb again with the command 'adb start-server'.
This then allows me to connect to the phone again
Another nugget of information for others that I found:
http://groups.google.com/group/android-developers/browse_thread/thread/5fb922c2166eab68
I had the usb plugged into the front of my computer and I was experiancing problems - after pluging it at the back direct to the usb controller and not a hub it has become much more reliable.
I had the same problem. Here is my solution: you have to connect the USB cable from your PC to your phone while pressing the power button of you phone.

Categories

Resources