startApplication() may fail to launch the Android application.
In such a case, please check/try the following points:
General¶
Make sure Android Studio is not running.
If the Android simulator needs to be used, do not start it from Android Studio, instead launch it via
android-sdk/emulator/emulator -avd avd-file(or similar).In the Squish IDE check the "Runner/Server Log" view for any error messages, in particular ones related to instrumentation.
Stop/kill an already running AUT by manually removing it from the Recent Apps list, or by executing "adb shell am force-stop com.example.YourApp" (using the "adb" shipping with Squish, in folder
SQUISH_DIR/bin; can be executed from the test script too).Increase "Maximum Startup Time" (in the Squish IDE) at Edit > Server Settings > Application Behavior.
Samsung-related¶
Try adding
--clear-app-settingsto the "Launcher Arguments" field in the test suite settings.Consider disabling Google Play Protect if it prevents automatic deployment of the app on the device.
Xiaomi-related (HyperOS)¶
On Xiaomi devices running HyperOS, Squish may fail to launch the AUT even with USB debugging enabled and Android Studio closed (see General section above). Two additional steps are usually needed:
Enable the extra ADB security setting:
- Navigate to Settings > Additional Settings > Developer options.
- Enable USB debugging.
- Also enable USB debugging (Security settings) — this allows simulated inputs and permission grants via ADB.
Grant the target application permission to start Activities while running in the background (HyperOS blocks this by default, which can cause Activity initialization to fail during recording/testing). Either:
- Via device Settings: go to Settings > Permissions > Other permissions, locate the target application, and set "Display pop-up windows while running in the background" (also labeled "Start in background" or "Open new windows while running in the background" depending on the version) to Always allow.
- Via ADB:
adb shell appops set <package_name> 10021 allow
Note: appop code 10021 corresponds to this permission on HyperOS only and is not part of AOSP — this command is confirmed to work on HyperOS but should not be assumed to work on other Android distributions or OEM skins.