自动化为Android发布版本版本、Android

2023-09-04 08:28:39 作者:弑神灭佛

我在一个文件夹10的Andr​​oid项目。对于每一个项目,我可以使用蚂蚁调试来建立它。所以这是没有问题的,写一个简单的脚本来编译所有这些项目。我用哈德森每日构建这些项目,并能正常工作。

I have ten Android projects in one folder. For each project, I can use ant debug to build it. So it is no problem to write a simple script to compile all these projects. I use Hudson to build these projects daily, and it works fine.

但是,现在我们的项目需要去释放阶段。因此编译命令变成蚂蚁发布。为编制发布的项目,我必须在编译过程中每次都输入密码证书。所以,我不能这样做自动释放。

But now our project needs to go to release phase. So the compile command becomes ant release. For compiling a release project, I have to enter the password for the certificate every time during compilation. So I can't do the automation for release.

这编译工作杀死我,因为我有十个项目都需要与输入密码进行交互。

This compiling job kills me since I have ten projects that all need to interact with inputting the password.

我怎样才能使发布版本还是自动?

How can I make the release build still be automatic?

推荐答案

假设你使用最新的Andr​​oid工具,说v9或V10。

Assuming you're using recent Android tools, say v9 or v10.

如果你看一下工具/ ANT / main_rules.xml 在Android SDK目录:

If you look at tools/ant/main_rules.xml in the Android SDK directory:

<!-- called through target 'release'. Only executed if the keystore and
     key alias are known but not their password. -->
<target name="-release-prompt-for-password" if="has.keystore" unless="has.password">
    <!-- Gets passwords -->
    <input
            message="Please enter keystore password (store:${key.store}):"
            addproperty="key.store.password" />
    <input
            message="Please enter password for alias '${key.alias}':"
            addproperty="key.alias.password" />
</target>

<!-- called through target 'release'. Only executed if there's no
     keystore/key alias set -->
<target name="-release-nosign" unless="has.keystore">
    <echo>No key.store and key.alias properties found in build.properties.</echo>
    <echo>Please sign ${out.unsigned.file} manually</echo>
    <echo>and run zipalign from the Android SDK tools.</echo>
</target>

搜索 has.keystore XML文件显示:

Searching the XML file for has.keystore reveals:

<!-- properties for signing in release mode -->
<condition property="has.keystore">
    <and>
        <isset property="key.store" />
        <length string="${key.store}" when="greater" length="0" />
        <isset property="key.alias" />
    </and>
</condition>
<condition property="has.password">
    <and>
        <isset property="has.keystore" />
        <isset property="key.store.password" />
        <isset property="key.alias.password" />
    </and>
</condition>

所以我认为你必须通过四个定义到build.xml: key.store key.alias key.store.password key.alias.password

和记住不要通过那些定义为安全起见在命令行上。 :)

And remember not to pass those defines on the command line for security reasons. :)