Can we override Appium's installing apk method?

I have an issue with running tests on Android. It just crashes at some certain point. It does not crash if I install it manually on simulator/device. So the way Appium push the apk to the device causes the issue. I have 2 questions. Why does that fact change the app behavior? Is there a way we can override the install method on Appium?

In my appium.txt I have only “appPackage” specified (no “app” property). Then Appium knows, which application should be tested, but doesn’t install it.
To install application, I use “adb install (path to apk file)” for Android and ideviceinstaller for iOS.
This configuration is also possible for Appium Gui.

1 Like

How do you configure “adb install (path to apk file)”?

I do the same as @czarnykwarc , I have a bash script set up as a pre-job in jenkins.

Can we achieve that via Appium instead, cuz when we run Appium, it’s gonna try to push the apk again.

It won’t if you dont specify “app” capability.

Thanks guys, for answering my questions. That sounds like a hack/workaround. Does anyone understand the root of the issue. If we can fix it from Appium side, that would be better. So, the question here is: Why does the way Appium installs apk change the behavior of the app?

This is a discussion board, I believe you will have better luck discussing changes to Appium on github, issues section. For example, I know that iOS installation process was revamped recently, to include ideviceinstaller instead of Fruitstrap.

Thanks, I just submitted an issue on Github.

I was unaware that the way Appium installs an app on Android could change the way the app behaves, maybe the people in this thread could help us figure it out?

All the relevant logic should be in this file here:

When Appium installs an app on Android, it does two thingsL First it signs the jar files, then it installs the app. It looks like the install process simply calls adb pm install -r <app> which seems pretty straightforward. Maybe the jar files get messed with in our signing process?

There’s a couple signing functions in the code linked above.

Yes and yes. The jar file got messed up in the signing process. I was able to fix my issue by change “noSign” cap to true. I tried this before, the reason it did not work before is that Appium already signed it before it installed the app. So, even I added “noSign” cap, it did not work. So i had replaced the apk with a new one (or you can do something else to update the signing process which I really don’t understand). And now it works. Just make sure to add “noSign” cap in the super class, so no tests will let Appium check and sign the app. Hope this helps. Thanks @jonahss for quick respond.


Can you think of a better place, or way to document this for our future users?