问题描述
这是一个真正的菜鸟问题.我在一家公司工作,该公司制作了 100 多个使用大部分相同组件的应用程序.在构建时有一些小的定制,我们希望加快速度以提高效率.大多数定制是在运行时从服务器下载数据完成的.
This is a real noob question. I work for a company that makes 100's of apps that use much of the same components. There is some minor customization at build time and we would like to speed that up to increase efficiency. The majority of the customization is done at runtime downloading data from a server.
我们完成项目 .apk 的最快速度大约是 15 分钟.此过程涉及更改包名称、图标和一些字符串资源.但是,当您每天处理 15-20 个可能成为实时杀手的应用时,我宁愿花时间编写新代码.
The fastest that we can get a project to a finish .apk is about 15 minutes. This process involves changing package names, icons, and a couple of string resources. But when you're dealing with 15-20 apps a day that can become a real time killer and I'd rather spend my time writing new code.
我读过有关使用 Maven 或 Gradle 来简化构建过程的文章,但我不确定这是否是减少构建时间的最佳方法.坦率地说,我什至不知道它们是否是合适的工具.
I've read about using Maven or Gradle to streamline the build process but am not really sure if this the best way to go about decreasing build time. Frankly I don't even know if they are the appropriate tools or not.
有人可以向我解释一下,使用这些工具中的一种是否可以完成我正在寻找的东西,或者是否有其他方法可以减少构建时间?任何建议将不胜感激.
Can someone please explain to me if using one of these tools would accomplish what I'm looking for or if there is some other way to decrease build times? Any suggestion would be appreciated.
推荐答案
采用一些命令行构建工具如 Maven 或 Ant 绝对是正确的方向,它使使用 Unix/Windows shell 脚本批处理构建过程成为可能.
Adopting some command-line build tools like Maven or Ant is definitely the right direction to go, it enables the possibilities of batching build process using Unix/Windows shell scripts.
将 maven-properties-plugin 和 android-maven-plugin 一起使用很容易实现您需要的那些小自定义.android-maven-plugin 支持资源过滤.您可以将每个构建周期的自定义属性定义到多个属性文件中,在构建过程中,android-maven-plugin 可以从外部属性文件中读取这些值,并替换 AndroidManifest.xml 和其他资源文件(如 res/values/)中的这些值字符串.xml.android-maven-plugin 还全面支持 Android Library Project,让您提取/集中通用的 android 代码,轻松管理所有代码.
Those minor customization you required are quite easy to achieve using maven-properties-plugin and android-maven-plugin together. android-maven-plugin support resource filtering. you can define your customized properties for each build cycle into several properties files, during the build process, android-maven-plugin can read those value from external properties file and substitute those value in AndroidManifest.xml and other resource file like res/values/strings.xml. android-maven-plugin also fully support Android Library Project, which let you extract/centralize common android code and manage all of them easily.
假设您想从同一个 Android 项目构建 5 个具有不同包/应用程序名称、应用程序图标和 string.xml 中的一些资源的 apk 发行版,您可以创建 shell 脚本 run mvn deploy 5 次,每次复制其中一个将带有适当的其他 icon.png 文件的 custom.properties 文件放入项目目录并覆盖现有的.这为您提供了不需要任何人工交互的端到端自动构建批处理.
Suppose you want to build 5 apk distributions from a same Android Project with different package/app name, app icon and some resources in string.xml, you can create shell script run mvn deploy 5 time,with each time copy one of your customize.properties with proper other icon.png files into the project directory and overwrite the existing one. this gives you an end-to-end auto build batch processing that doesn't need any human interaction.
您可以找到一个示例项目 MorseFlash 检查资源android-maven-plugin 使用的过滤.
You can find a sample project MorseFlash examine the resource filtering used by android-maven-plugin.
这篇关于加快 Android 构建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!