'Connection to AUT refused' is the most common symptom when having trouble with getting Squish to connect to a Qt AUT on an Android device. The sections in this article illustrate what needs to be verified in order to isolate the reason for the failing tests.
There are some points in the configuration of the App project, that can explain why Squish can not connect to the App during a test run.
- Ensure you include "qtbuiltinhook.pri" from a Squish package for the right Android ABI (meaning cpu architecture of the target device).
- Qt 5.14/5.15 support building applications for multiple ABIs, only select exactly one of them when building Squish (ABI selection in Qt Creator found in Projects -> Build -> Build Settings -> Build Steps -> qmake)
- Sometimes qmake can screw up when new dependencies are added in a project. You should make sure, that the following message shows up in the output from qmake in the Qt Creator Compile window after modifying the project.
Project MESSAGE: Squish: including builtin-hook in APPNAME build/deployment
- After executing qmake, you should check that the toplevel build directory contains the file "squishqtattach_port" which should contain the port number from the SQUISH_ATTACH_PORT qmake variable in the project file. It will become part of the application
After building the project the following things can be checked.
- Ensure that
"BUILDDIR/android-build/assets/squish/"exists. The folder should contain the files 'qtwrapper.ini','squishqtattach_port' among several .ext Files, as well as a folder with the name qtquick, that contains extensions for the qtquick support.
- Ensure that
"BUILDDIR/android-build/libs/ARCHITECTURE/"contains not only Qt and application libraries but also several files starting with
- Once the final APK has been created below
"BUILDDIR/android-build/build/outputs/apk/debug/"you can also verify its contents. Since APK files are ZIP compressed archives their file contents can be inspected with the respective tools.
The following command should list several Squish files again, just like the ones from the previously mentioned "assets" and "libs" directories:
unzip -l android-build-debug.apk | grep squish
On Windows you should be able to use the default zip tool. There is also the open source tool 7zip, that can be used.
When the socket connection can not be established it can also be helpful to inspect what the application does during and after being launched.
To see what the application is doing during startup start execute the following command on a terminal before starting the Application:
adb logcat > $HOME/logcat_output.log
adb logcat > %USERPROFILE%/logcat_output.log
When you have started the Application, you can end the adb process on the shell.
Alternatively start the application from Qt Creator itself which will show log output in the "Application Output" tab.
- The log should contain the following message after the application launch if there was no issue.
Squish: Listening on port NNNN for incoming connections
- While the application is running one can also check if it can be attached on the configured port via adb:
adb shell netstat -a | grep NNNN
- To check if the connection can be made from the outside, a third party tool like putty or telnet can be used. As another alternative the Python script offered in the article Connection to AUT refused has a similar functionality.