Home » Android » android ant build: debug and release targets

android ant build: debug and release targets

Posted by: admin June 15, 2020 Leave a comment

Questions:

According to the ‘help’ target documentation:

  1. debug: builds the applications and
    signs it with a debug key
  2. release; builds the application: the
    generated APK file must be signed
    before it is published

Here is what I found, which is a bit different than what I expected:

debug: ignores keystore definitions in build.properties whether you specify them or not. Which kesystore file is it using? The same as Eclipse: the default debug.keystore file in your Documents and Settings?

It creates two files:

  1. -debug-unaligned.apk (signed, unaligned)
  2. -debug.apk (signed, aligned)

release: ‘help’ says it doesn’t sign it. It creates these files:

  1. -unsigned.apk (unsigned, unaligned)

The next two are only if you have the values specified in build.properties:

  1. -unaligned.apk (signed, unaligned)
  2. -release.apk (signed, aligned)

Any helpful comments / verifications will be greatly appreciated.

How to&Answers:

Which kesystore file is it using? The same as Eclipse: the default debug.keystore file in your Documents and Settings?

Yes.

Answer:

As far as the release target goes, you will get behaviour like this:

If you have lines like:

key.store=c:/users/me/my-release-key.keystore
key.alias=release_alias
key.store.password=myStorePassword
key.alias.password=myAliasPassword

in your build.properties, it will automatically build and sign your apk with no prompting for anything.

If you comment out the last two lines, then it will prompt you for the passwords, then complete a signed build if the passwords are OK.

If you don’t have any of the above lines, then it will just build you an unsigned apk with no prompting for anything and end with:

-release-nosign:
[echo] No key.store and key.alias properties found in build.properties.
[echo] Please sign C:\dev\projects\AntBuilds\MyProject\bin\MyProject-unsigned.apk manually
[echo] and run zipalign from the Android SDK tools.

.

Answer:

This answer works for me, I am using ant to auto-compile android app, it prompts and need password, I wrote one file named password, and using the command —ant release < passwd,
However, it also prompts that I need input password.

Using the tips here

key.store=c:/users/me/my-release-key.keystore
key.alias=release_alias
key.store.password=myStorePassword
key.alias.password=myAliasPassword

I solved this problem.