Android Driver RemoveApp

If I use the androiddriver.removeApp(<package name>);, I am getting the following error

[debug] [W3C (08e37f07)] Encountered internal error running command: Error: Unable to uninstall APK. Original error: Error executing adbExec. Original error: 'Command '/Users/<user>/Library/Android/sdk/platform-tools/adb -P 5037 -s R9WR7102GEF uninstall com.test.support_mobile.staging' timed out after 40000ms'. Try to increase the 40000ms adb execution timeout represented by 'adbExecTimeout' capability [debug] [W3C (08e37f07)] at ADB.uninstallApk (/usr/local/lib/node_modules/appium/node_modules/appium-adb/lib/tools/apk-utils.js:382:11) [debug] [W3C (08e37f07)] at AndroidUiautomator2Driver.removeApp (/usr/local/lib/node_modules/appium/node_modules/appium-android-driver/lib/commands/app-management.js:91:10)

I increased the timeout. But it still timed out.

Found out that the adb uninstall ... command being passed requires the --user 0 flag to be passed for successfully uninstalling the APK. How do I pass that flag?

Any guidance very much appreciated thank you.

If you try execute it manually will it suceed?
Hope this is not app that under test…

Hi Aleksei, this is the app under test, when I try the adb uninstall it hangs. If I use the --user 0 flag then it works.

why you need uninstall? why not just simple reset?
uninstall same app that was used to start driver … this possibly is a problem.

Sorry forgot to mention, that on Emulator ‘removeApp()’ works perfectly. It is on the actual device (Tablet) that I am facing the problem.

You are probably right, that I should just re-install on top of what is there, but the installation fails if an older version is already installed. I might have to do some digging around here to see what is going on. Probably some config problem at my end.


I want to uninstall to set the device back to init state so I can install next version of the APK. Want to config this into a CICD pipeline.

why not just start driver correctly depending on your needs? -> Different capabilities for different scenarios

1 Like

Thank you. Will check it out.