如何为 Android ant 调试版本指定调试密钥库的位置? [英] How can I specify location of debug keystore for Android ant debug builds?

查看:27
本文介绍了如何为 Android ant 调试版本指定调试密钥库的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在创建调试 .apk 的 (-debug.apk) 时指定自创建的调试密钥库的位置蚂蚁调试?我只看到了指定发布密钥库位置的可能性.

Is it possible to specify the location of a self created debug keystore when creating debug .apk's (<project-name>-debug.apk) with ant debug? I only see the possibility to specify the location of the release keystore.

我想在多台 PC 上共享调试密钥库,而不是将它们复制到位于.android"目录中的那个.例如,调试密钥库可以驻留在源代码存储库中.但是我需要一种方法来告诉 ant 在哪里可以找到调试密钥库.

I would like to share the debug keystore over multiple PC's without copying them over the the one that is placed in the '.android' directory. The debug keystore could for example reside within the source code repository. But I need a way to tell ant where to find the debug keystore.

推荐答案

你可以去掉最终 apk 的签名,然后重新签名.这只是一个调试版本,因此可以避免 zipalign(至少我的版本没有问题).

You can remove the signature of the final apk and sign it again. It is just a debug build so the zipalign can be avoided (at least I have no problems in my build).

将您的密钥库复制到项目中的文件 debug.keystore 并在 ant.properties 中添加以下内容

Copy your keystore to a file debug.keystore in the project and add the following in ant.properties

debug.key.store.password=android
debug.key.alias.password=android
debug.key.store=../debug.keystore
debug.key.alias=androiddebugkey

并在 build.xml 中添加以下内容

And add the following in your build.xml

<target name="-post-build" if="${build.is.packaging.debug}">
    <!-- Remove the signature of the debug build, and sign it again with our own debug keystore -->
    <delete dir="tmp" includeemptydirs="true" failonerror="false" />
    <mkdir dir="tmp" />
    <unzip src="${out.final.file}" dest="tmp" />
    <delete dir="tmp/META-INF" includeemptydirs="true" verbose="true" failonerror="true" />
    <delete file="${out.final.file}" failonerror="true" />
    <zip destfile="${out.final.file}" basedir="tmp" />
    <delete dir="tmp" includeemptydirs="true" failonerror="false" /> 

    <echo level="info">Signing final DEBUG apk with a common signature...
        signapk
            input="${out.final.file}"
            output="${out.packaged.file}"
            keystore="${debug.key.store}"
            storepass="${debug.key.store.password}"
            alias="${debug.key.alias}"
            keypass="${debug.key.alias.password}"
    </echo>

    <signapk
        input="${out.final.file}"
        output="${out.packaged.file}"
        keystore="${debug.key.store}"
        storepass="${debug.key.store.password}"
        alias="${debug.key.alias}"
        keypass="${debug.key.alias.password}"/>

    <delete file="${out.final.file}" failonerror="true" />
    <move file="${out.packaged.file}" tofile="${out.final.file}" failonerror="true" />

</target>

这篇关于如何为 Android ant 调试版本指定调试密钥库的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆