How can I specify location of debug keystore for Android ant debug builds? How can I specify location of debug keystore for Android ant debug builds? android android

How can I specify location of debug keystore for Android ant debug builds?


You should be able to specify the keystore to use with these properties

key.store=/path/to/key.keystorekey.alias=aliaskey.store.password=passkey.alias.password=pass

Just pass the properties in to Ant.

[EDIT]From the docs at http://developer.android.com/guide/publishing/app-signing.html#setup

The Android build tools provide a debug signing mode that makes it easier for you to develop and debug your application, while still meeting the Android system requirement for signing your .apk. When using debug mode to build your app, the SDK tools invoke Keytool to automatically create a debug keystore and key. This debug key is then used to automatically sign the .apk, so you do not need to sign the package with your own key.

The SDK tools create the debug keystore/key with predetermined names/passwords:

  • Keystore name: "debug.keystore"
  • Keystore password: "android"
  • Key alias: "androiddebugkey"
  • Key password: "android"
  • CN: "CN=Android Debug,O=Android,C=US"

If necessary, you can change the location/name of the debug keystore/key or supply a custom debug keystore/key to use. However, any custom debug keystore/key must use the same keystore/key names and passwords as the default debug key (as described above). (To do so in Eclipse/ADT, go to Windows > Preferences > Android > Build.)


As far as I can tell, in order to do this you need to override the "-do-debug" target. I'd like to know if there's a more elegant way, though. I added this to my build.xml

<property name="build.is.signing.debug" value="false"/><target name="-do-debug" depends="-set-debug-mode, -debug-obfuscation-check, -package, -post-package">    <!-- only create apk if *not* a library project -->    <do-only-if-not-library elseText="Library project: do not create apk..." >        <sequential>            <property name="out.unaligned.file" location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" />            <!-- Signs the APK -->            <echo>Signing final apk...</echo>            <signjar                    jar="${out.packaged.file}"                    signedjar="${out.unaligned.file}"                    keystore="${key.store}"                    storepass="${key.store.password}"                    alias="${key.alias}"                    keypass="${key.alias.password}"                    verbose="${verbose}" />            <!-- Zip aligns the APK -->            <zipalign-helper                    in.package="${out.unaligned.file}"                    out.package="${out.final.file}" />            <echo>Debug Package: ${out.final.file}</echo>        </sequential>    </do-only-if-not-library>    <record-build-info /></target><import file="${sdk.dir}/tools/ant/build.xml" />


  • Create a new and empty folder within your Eclipse workspace.

  • Copy the file "debug.keystore" from its standard location (e.g. "c:/Users/YourAcount/.Android/" on Windows) into that new directory.

  • Configure Eclipse to use that new directory/file for all Debug APKs (Eclipse --> Window --> Preferences --> Android --> Build --> Custom Debug Keystore".