Can't run tests unless I restart io.appium.settings

So I have this problem where I can not start my app, unless I kill io.appium.settings in adb.
How it woks is: The app will open and close several times, but no tests will run. Then I get this message:

ERROR: An unknown server-side error occurred while processing the command. Original error: Cannot start the 'my.app.package' application. Visit https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/activity-startup.md for troubleshooting. Original error: Error executing adbExec. Original error: 'Command '/home/me/Android/Sdk/platform-tools/adb -P 5037 -s emulator-5554 shell am start -W -n my.app.package/host.exp.exponent.MainActivity -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000' exited with code null'; Stderr: ''; Code: 'null'

I can work around this by adb shell ps | grep appium and then
adb shell
su
kill {PID}
after which the test will start properly, but that is super annoying to do every time. Is there some permanent fix for this issue? I have not written any appPackage or appActivity capabilities.

Is this to do with the fact that this app was built by Expo? (the host.exp.exponent.MainActivity part).

1 Like

I hope you are using the capability mentioned below

capabilities.setCapability(“appActivity”, “First activity of the app”);

Yes, I tried setting every combination of appActivity and appPackage.

I manage to isolate the issue: It has to do with the apk. When I an apk from a different project, appium worked fine. This problem only occurs after I launch the same Expo apk twice in row. Seems that it is never properly closed or something.

Edit: Turns out it is most likely a problem with signing keystore. What could cause this?
Also, for the second login, I never get a session ID. I don’t know if this is relevant.

You better to uninstall the Appium related apps before creating the session.
This solve lot of issues related to connection refused, session creation issues.
Write a method to execute adb commands and pass the below commands one by one.

  • adb -s uninstall io.appium.settings
  • adb -s uninstall io.appium.unlock
  • adb -s uninstall io.appium.uiautomator2
  • adb -s uninstall io.appium.uiautomator2.server.test

Whenever appium starts to create session it will re-install/install below apps on to the device.

  • io.appium.settings
  • io.appium.unlock
  • io.appium.uiautomator2
  • io.appium.uiautomator2.server.test

I am also getting same issue after adding appActivity and AppPackage