Ant fails to build signed apk after updating to android v20
Asked Answered
P

5

5

Quite a bit of weird error is happening after I upgraded android and eclipse tools to v20

building through Ant stopped working with the following error upon creating the signed apk

 BUILD FAILED
 C:\Programs\Android\tools\ant\build.xml:1097: The following error occurred while executing this line:
 C:\Programs\Android\tools\ant\build.xml:1109: Cannot recover key

Any idea what could've changed when doing the upgrade to android JB components, and how can this be rectified?

I appreciate any help...

Palila answered 24/7, 2012 at 6:24 Comment(0)
P
3

I just spent about 5hr on this topic... It all came down to a space after the password.

Apparently in the prior version it was trimming the password and in the current version it does not.

So making sure you don't have spaces at the end of the lines might make the difference. That solved the problem for us - no need to go to JDK7 (although it seems to build and work just fine anyway, at least from ant).

Pickup answered 2/8, 2012 at 16:8 Comment(1)
You're a lifesaver @Roberto C Serrano. Also no extra empty lines at the end of the ant.properties file.Palila
E
8

We have had the same problem, and we have a solution but not really an explanation!

Our existing builds had the following in properties files:

  • key.store=COMPANY_NAME-key.keystore
  • key.alias=COMPANY_NAME
  • key.store.password=KEY_STORE_PASSWORD
  • key.alias.password=KEY_ALIAS_PASSWORD

But this has stopped working – however when we change the key.alias.password to match the store password it is working eg:

  • key.store=COMPANY_NAME-key.keystore
  • key.alias=COMPANY_NAME
  • key.store.password=KEY_STORE_PASSWORD
  • key.alias.password=KEY_STORE_PASSWORD

Alias not sure why, perhaps someone has mucked up the ant library?

Endrin answered 26/7, 2012 at 22:33 Comment(2)
Thanks for the response uesr1556185. You're reply actually rose more questions. The thing is that my store and alias passwords have been the same from the very start... By the way I can nicely export a signed apk using the eclipse android tools - Right Click On the project > Android Tools > Export Signed Application Package...Palila
Glad it works for you HefferWold, sorry it didn't for Nar Gar. I'm a bit at a loss what to suggest, I have taken a look at the Git source for the SignApk ant target and can't see anything obviously wrong. It does mention some changes in the signing process - the check in is here: android.googlesource.com/platform/sdk/+/… can't see why that would be a problem. Which JDK are you using? Perhaps SDK 7 might work?Endrin
P
3

I just spent about 5hr on this topic... It all came down to a space after the password.

Apparently in the prior version it was trimming the password and in the current version it does not.

So making sure you don't have spaces at the end of the lines might make the difference. That solved the problem for us - no need to go to JDK7 (although it seems to build and work just fine anyway, at least from ant).

Pickup answered 2/8, 2012 at 16:8 Comment(1)
You're a lifesaver @Roberto C Serrano. Also no extra empty lines at the end of the ant.properties file.Palila
C
2

Beware of the Error-Message:

Wrong key.store.password leads to:

Keystore was tampered with, or password was incorrect: Password verification failed

Whereas a wrong key.alias.password leads to:

Cannot recover key

For everone who checked only the store-password by keytool -v -list mykeystore.keystore and never verfied the alias.password.

Collyer answered 28/8, 2013 at 12:10 Comment(0)
H
1

Prior to SDK v20, I had built a project using a bash script, entering the passwords like this:

build_v1.sh

ant release
p@ssw0rd
p@ssw0rd

In v20 it fails because the password isn't being accepted. It appears to be related to the end of line character, but I'm not sure. To prevent the build process from asking for the password, you can add password properties to the ant.properties file:

ant.properties

key.store=company-key.keystore
key.alias=company
key.store.password=p@ssw0rd
key.alias.password=p@ssw0rd

For my specific project, a fake keystore password is saved in ant.properties and I am replacing it with the release keystore password at build time:

build_v2.sh

keyPass=p@ssw0rd
sed -i "s|key.store.password=.*|key.store.password=${keyPass}|g" ant.properties
sed -i "s|key.alias.password=.*|key.alias.password=${keyPass}|g" ant.properties
ant release

This allows our release keystore password to be stashed elsewhere. Good luck!

Hydrography answered 15/8, 2012 at 18:49 Comment(0)
B
0

It looks like your debug key is not seen by ant.

Ballarat answered 24/7, 2012 at 22:52 Comment(1)
Thanks for the response, build xml is configured to sign the app with the release key. That setting is specified in the ant.properties file the path to which is specified in the build.xml file. Please note that everything was working before upgrading Android and eclipse tools to v20 (Jelly beans)Palila

© 2022 - 2024 — McMap. All rights reserved.