Question

I have access to the code for the app I am testing (myApp) and I have a suite of tests (myTest). When I run my tests, Eclipse compiles and installs both myApp and myTest and all the tests run fine. So far, so good. Now I also want to be able to execute these tests against an apk of myApp, and I cannot get this to work due to signing issues.

As I understand it, the solution is to re-sign myApp.apk with the Android debug keystore's signature so that myTest.apk and myApp.apk will have the same signature. Renas' Robotium tutorial on the subject recommends a tool to do this, re-sign.jar. This tool does seem to work, I can install and run the resulting apk file, but it doesn't wind up with the same signature as myTest. In other words, when I run myTest (debug in eclipse, or from commandline) I get the error complaining that the test failed because myApp and myTest don't have the same signature.

I can work around this if I use re-sign.jar to re-sign both myApp.apk AND myTest.apk. (although this is not a solution, since I cannot debug, only run the tests from the commandline. Also, it's ugly.) I don't understand why this should be - since myTest.apk was created automatically when I ran my test in eclipse, it should already have been signed with the debug keystore, and re-sign.jar should just reapply the same signature, right?

Maybe that tool is outdated or broken. Well, Renas' tutorial also includes steps to re-sign the jar manually, like so:

jarsigner -keystore c:\androiddev\.android\debug.keystore 
    -storepass android -keypass android C:\blah\myApp.apk androiddebugkey
zipalign 4 C:\blah\myApp.apk C:\blah\myApp2.apk

This sems to work, and the afterwards, running "jarsigner -verify" returns "jar verified". However, the resulting apk will not install:

C:\blah>adb install myApp.apk
    3739 KB/s (1922522 bytes in 0.502s)
    pkg: /data/local/tmp/myApp.apk
Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES]

Can anyone tell me what's going on here? Stack has several other questions about "How do I use Robotium on an apk" and the answer is that tutorial I linked to earlier, but both methods of signing the apk listed in that tutorial fail for me.

Was it helpful?

Solution

The issue was caused by having Java 7 installed and using instructions for Java 6. I was able to sign the apk and install it after adding these params: -sigalg MD5withRSA -digestalg SHA1 Working commands:

jarsigner -keystore c:\androiddev\.android\debug.keystore 
    -storepass android -keypass android C:\blah\myApp.apk androiddebugkey
    -sigalg MD5withRSA -digestalg SHA1      
zipalign 4 C:\blah\myApp.apk C:\blah\myApp2.apk
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top