多个版本的Android应用程序
看到没有预处理器指令(没有 跳过一些障碍),我想知道是否有一个接受的执行以下操作的方法:
- 在常规的 Android 市场中拥有一个 Android 应用程序,该应用程序使用相机、麦克风等。
- 根据某些构建参数有条件地“交换”某些功能。
- 生成两个 APK,每个商店一个
理想情况下,我希望将 ANT 体操保持在最低限度...并且理想情况下不必维护两组文件(即 google_activity_layout.xml 和 amazon_activity_layout.xml)。
编辑:这个答案看起来很有趣:https://stackoverflow.com/a/1813873/5416 >
Seeing as how there are no preprocessor directives (without jumping through some hurdles), I was wondering if there was an accepted way of doing the following:
- Have an android app in the regular ol' android market that uses things like the camera, mic, etc.
- Conditionally "swap out" certain features based on some build parameter.
- Produce two APKs, one for each store
Ideally, I would want to keep the ANT gymnastics to a minimum ... and also ideally would not have to maintain two sets of files (ie. google_activity_layout.xml and amazon_activity_layout.xml).
edit: this answer looks interesting: https://stackoverflow.com/a/1813873/5416
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经能够使用 XMLTask antlib 来修改 AndroidManifest.xml 作为 -pre-build 挂钩的一部分。我没有使用您链接的机制,但我认为修改权限和使用链接机制的组合可以实现您的目标。由于权限是在运行时与编译时检查的。
您可以在此处找到该库:http://www.oopsconsultancy.com/software/xmltask/
需要注意的一件事是,这需要一些修补。由于 apk 的编译方式,我的“蚁猴生意”确实花了几个小时的时间进行修补。如果您愿意运行完整的构建几次,那么应该不会那么困难,并且可能只需将一个全新的任务添加到生成的 build.xml 的开头即可。如果您有疑问,请告诉我,因为我一直在修改这些东西。
I have been able to use XMLTask antlib to modify the AndroidManifest.xml as part of the -pre-build hook. I haven't used the mechanism you linked, but I would think that a combination of modifying the permissions and using the linked mechanism would achieve your goal. Since the permissions are checked at runtime vs. at compile time.
You can find the library here: http://www.oopsconsultancy.com/software/xmltask/
One thing to note, it will take some tinkering. My "ant monkey business" did take several hours of tinkering because of the way the apk is compiled together. If you are willing to run the full build a few times it should be less arduous and could probably just ad a completely new task to the beginning of the build.xml that is generated. Let me know if you have questions as I've been tinkering with this stuff a lot.