如何从命令行编译APK? [英] How to compile APK from command line?

查看:200
本文介绍了如何从命令行编译APK?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣按需安装Android应用程式。根据客户的要求,我的网站会将JSON文件直接发送到我在Delphi中创建的Windows应用程序。这个将文件保存在Android应用源文件夹中,然后执行一个命令行,告诉Android编译器生成APK文件并将其发送到我的客户端,所有这些都没有我的存在。

I am interested in making Android apps on demand. Depending on the clients request, my web site would send me a JSON file direct to a Windows application that I have created in Delphi. This one would save the file inside the Android app source folder and then, execute a command line telling the Android compiler to generate the APK file and send it to my client, all that without my presence.

Android项目是通过 MotoDev 进行的。它使用的是我的根目录中的Android SDK。

The Android project was made with MotoDev. And it uses the Android SDK that is in my root.

如何配置命令行以从Delphi程序内部实现?

How should I configure the command line to achieve this from inside my Delphi program?

我还需要更改清单以放置新版本号,以免与其他客户端版本冲突。

I will also need to change the manifest to put a new version number so it does not conflict with other clients version.

推荐答案

Android使用Ant构建系统,所以您可以为您的项目创建一个 build.xml build.properties 文件。

Android uses the Ant build system, so you can create a build.xml and build.properties file for your project.

您需要先创建 build.xml 文件:

android update project -p .

这将生成一个 build.xml 文件。您应该可以自定义项目的构建步骤和目标。在你的情况下,一个好主意就是让您的网站为特定版本生成的 build.properties 文件...然后通过 build.xml 文件。特别是,您需要在签名密钥所在的 build.properties 文件中指定密码:

This will generate a build.xml file. You should probably customize the build steps and targets for your project. A good idea in your case would be to have the build.properties file generated by your website for the specific build... Then include it via the build.xml file. In particular, you will need to specify in the build.properties file where the signing keys are, and what the password is:

Build.Properties:

key.store=keystore.dat
key.alias=signing_key
key.store.password=password123
key.alias.password=password123

使用 ant 的构建过程也允许您在Java文件中进行可变替换,这可能是另一个想法。它将允许您根据客户端在客户端进一步自定义构建过程。

The build process using ant also allows you to do variable replacements in Java files, which might be another idea. It would allow you to customize the build process further on a client by client basis.

默认情况下,构建由以下触发:

By default, the build is triggered by:

ant clean
ant release

另一个简单的想法:让Ant将生成的APK文件复制到网站可访问的网络共享中,方法是将中复制... /> 目标名称=发布> 部分。

Another neat idea: Have Ant copy the resulting APK file to a network share accessible by the website by placing a < copy ... /> line in the < target name="release" > section.

这篇关于如何从命令行编译APK?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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