构建配置特定资源(调试与发布) [英] Build Configuration Specific Resources (Debug vs. Release)

查看:130
本文介绍了构建配置特定资源(调试与发布)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一个聪明的方法,最好使用Eclipse / ADT的工作流程,对特定资源的申请,取决于它是一个调试一个项目或发布版本(在Eclipse即应用程序是否运行或出口)?常见的使用情况下,我们遇到的所有时间,这与API密钥(如地图)。这将是巨大的,建立一个项目,有一个的strings.xml文件专门为所有的调试字符串,然后一个单独的一个用于所有版本字符串。

Does anyone know of a clever way, ideally using the Eclipse/ADT workflow, to apply specific resources to a project depending on whether it was a debug or release build (i.e. in Eclipse whether the application was Run or Exported)? The common use case we run into all the time for this is with API keys (like Maps). It would be great to set up a project to have a strings.xml file specifically for all the debug strings, and then a separate one for all the release strings.

有没有办法做到这一点,而无需移动到建筑物的Ant或Maven风格呢?

Is there any way to do this without needing to move to the ANT or Maven style of building?

推荐答案

尽管这不是你问什么,我强烈建议自动化发布版本,只要你想的是一致的,正确的每一个你建立起来的时间。

Although it's not what you've asked for, I highly recommend automating the release build as you want that to be consistent and correct every time you build it.

有关的发展,你可以继续使用Eclipse的工作流程在这种情况下。对于我自己的应用程序,阴雨天,我切换了调试VS在Ant编译版本映射键。我给自己定一个字符串资源地图键和替换字符串中的ant构建。然后,我用詹金斯打造的释放,从詹金斯得到祝福的apk,如果生成成功。关于这种做法的好处是,你可以进一步自动化构建单元测试和设备安装测试以自动方式。

For development you can keep using the Eclipse workflow in that case. For my own app, Rainy Days, I switch out the debug vs release map keys in the ant build. I've set the map key in a string resource and replace that string in the ant build. I then build the release using Jenkins and get the blessed apk from Jenkins if the build succeeds. The nice thing about that is that you can further automate the build with unit tests and device installation tests in an automated fashion.

恕我直言,你不应该检测调试版本在code,因为它增加了更多的code路径,让您的code更复杂,甚至引入了开销在运行时在某些情况下。

IMHO you shouldn't be detecting debug builds in your code, as it adds more code paths and makes your code more complex, and even introduces overhead at runtime in some cases.

这篇关于构建配置特定资源(调试与发布)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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