Ant fails to build signed apk after updating to android v20

天涯浪子 提交于 2019-12-06 04:01:12

问题


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...


回答1:


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).




回答2:


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?




回答3:


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.




回答4:


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!




回答5:


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



来源:https://stackoverflow.com/questions/11625262/ant-fails-to-build-signed-apk-after-updating-to-android-v20

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!