我想自定义构建过程,同时仍然使用 Android Eclipse ADT 插件
安装 ADT 插件后,以下构建器对于 Android 项目是活动的:
- Android 资源管理器
- Android 预编译器
- Java 构建器
- Android 包构建器
查看输出目录,将创建以下工件:
- resources.ap_ (只是一个 APK/ZIP有资源且无代码)
- gen/R.java (自动生成的资源列表)
- .class 文件,带有 java 字节码
- classes.dex
- ${project-name}.apk
对于我的项目,我自动生成了几个代码工件,并且通常需要更严格的控制构建过程。起初,我认为资源管理器负责创建resources.ap_,预编译器创建R.java,java builder做了显而易见的事情,然后Android Package Builder创建了classes.dex,然后将classes.dex和resources.ap_组合起来创建 APK 文件。
我禁用了前两个步骤,并创建了一个自定义预构建器,该预构建器放置了 resources.ap_ 的副本,认为这将是等效的。没有这样的运气。
不幸的是,最终的 Android Package Builder 似乎直接从 res/ 获取资源并忽略了我的 resources.ap_。事实上,前两个构建步骤除了生成 R.java 之外似乎没有做太多事情。
这才是真正有问题的地方。如果我禁用最后的构建步骤并放置我自己的 APK 文件(具有完全相同相同的名称),我会收到以下错误:
[2011-02-27 20:25:28 - android-premium] ------------------------------
[2011-02-27 20:25:28 - android-premium] Android Launch!
[2011-02-27 20:25:28 - android-premium] adb is running normally.
[2011-02-27 20:25:28 - android-premium] Could not find android-premium.apk!
所以我陷入困境:使用 Android Package Builder(它没有可辨别的配置),我必须提供单独的 ./res/ 文件。没有它,我无法在设备上启动项目(不是从 Eclipse)。
有人在这个领域有更好的想法/经验吗?
With the ADT plug-in installed, the following builders are active for an Android project:
- Android Resource Manager
- Android Pre Compiler
- Java Builder
- Android Package Builder
Looking at the output directory, the following artifacts are created:
- resources.ap_ (just an APK/ZIP with resources and no code)
- gen/R.java (autogenerated list of resources)
- .class files with java bytecode
- classes.dex
- ${project-name}.apk
For my project, I autogenerate several code artifacts and in general need tighter control of the build process. At first, I figured that the Resource Manager was responsible for creating resources.ap_, the precompiler created R.java, java builder did the obvious, and then the Android Package Builder created classes.dex, then combined classes.dex and resources.ap_ to create the APK file.
I disabled the first two steps and created a custom pre-builder that laid down a copy of resources.ap_, figuring this would be equivalent. No such luck.
Unfortunately, the final Android Package Builder seems to slurp the resources directly from res/ and ignores my resources.ap_. In fact, the first two build steps don't seem to do much other than generate R.java.
This is where it gets really problematic. If I disable the final build step and lay down my own APK file (with the exact same name), I get the following error:
[2011-02-27 20:25:28 - android-premium] ------------------------------
[2011-02-27 20:25:28 - android-premium] Android Launch!
[2011-02-27 20:25:28 - android-premium] adb is running normally.
[2011-02-27 20:25:28 - android-premium] Could not find android-premium.apk!
So I'm stuck: with the Android Package Builder (which has no discernable configuration), I have to supply individual ./res/ files. Without it, I can't get the project to launch on the device (not from Eclipse).
Anyone have any better ideas / experience in this space?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
关于 Ant 脚本,以下是我构建 Android 应用程序的 Ant 步骤的一体化模板(这对于尝试将 Eclipse 构建转换为 Ant 的其他人可能有用,因为它比不透明版本更简单、更透明使用 android 工具自动生成):
我正在寻找的是能够使用此 Ant 构建脚本的全部或片段,但仍然具有用于启动和调试应用程序的 Eclipse 集成。
Regarding Ant scripts, the following is my all-in-one template of the Ant steps for building an Android app (this might be useful to others trying to translate the Eclipse build to Ant as it is much simpler and more transparent than the opaque version autogenerated with the android tools):
What I am looking for is to be able to use all or fragments of this Ant build script, but still have the Eclipse integration for launching and debugging the app.
我们使用 Ant 脚本来完成 android 项目的构建过程,其他人也使用 Maven。这些很有帮助,因为您可以将它们编写为每天运行的脚本,作为夜间构建的一部分,作为 CI 构建系统的一部分。在高级级别,您可以编写脚本来完成发布构建,包括发布标签、预编译和后编译 AndroidManifest.xml 修改和签名。
We have used Ant scripts to do the build process for android projects, others have also used Maven. These help as then you can script them to run every day as part of nightly builds, as a part of your CI build system. At an advanced level you can script this to do release builds complete with release tags, pre-compilation and post-compilation AndroidManifest.xml modifications and signing.