Android .apk turned into .tmp file

I’m running into a strange problem installing the app on multiple devices. When I run my tests in parallel on Jenkins, the job fails because at some point it looks the apk files turns into a .tmp file. When this happens, another parallel thread cannot find the file “e.g. android-nightly-debug.apk” because now it’s renamed “1432658816751.tmp”. Anyone else experienced this issue? I’d appreciate any help on this. Thanks!

e[31merrore[39m: Failed to start an Appium session, err was: Error: Command failed: /bin/sh -c java -jar /usr/local/lib/node_modules/appium/node_modules/appium-adb/jars/sign.jar /Users/Shared/Jenkins/Home/jobs/ANDROID/lastSuccessful/archive/android/build/outputs/apk/android-nightly-debug.apk --override error in opening zip file
at Method)
at java.util.jar.JarFile.(
at java.util.jar.JarFile.(
at s.Sign.sign(
at s.Sign.main(

e[31merrore[39m: Failed to start an Appium session, err was: Error: Could not sign apk. Are you sure the file path is correct: “/Users/Shared/Jenkins/Home/jobs/ANDROID/lastSuccessful/archive/android/build/outputs/apk/android-nightly-debug.apk”

Ok, so this was a major pain to figure out, but have a workaround now. I guess before installing an app on a real device, appium has to code sign it. My problem was occurring when I run in parallel against multiple real devices, the code signing was renaming the file to a .tmp file in one thread, so another thread would fail because couldn’t find the .apk file.

I got around this by running the same code signing script Appium uses on my .apk file before my script splits into parallel processes. When the appium object is loaded it detects if the app is signed and doesn’t have to rename it to a .tmp file. I hope this helps someone because this was a PITA to sort out.

Below is an example of my workaround. I’m sure there is a more elegant approach but this works for now.

$ java -jar appium/node_modules/appium-adb/jars/sign.jar sample.apk (creates sample.s.apk)
$ rm sample.apk (remove unsigned app)
$ mv sample.s.apk sample.apk (rename signed to original name)

1 Like

Thanks, that works for me too.

I’ve used --overrite option instead of file move

java -jar appium/node_modules/appium-adb/jars/sign.jar android.apk --override