[英]How to build different APKs with same source code but different resources
Mainly this is for branding. 主要是为了品牌。 I hope to use different set of images and drawable resources for different clients.
我希望为不同的客户使用不同的图像集和可绘制资源。
What I hope to achieve is that when at build phase, I could select which resources pack I need to use, but leave the source code untouched. 我希望实现的是,在构建阶段,我可以选择我需要使用的资源包,但保持原始代码不变。
I know I could just create multiple projects by copy and paste, or I could create one project but change the res folder everytime I build it. 我知道我可以通过复制和粘贴来创建多个项目,也可以创建一个项目,但是每次构建时都更改res文件夹。 What I need help is that is there a more funcional way to achieve this task?'
我需要帮助的是,还有没有更多的功能可以完成此任务?
Thank you! 谢谢!
Already done: 已经完成了:
Use a project as a library, with all the drawables (default). 将项目与所有可绘制对象一起用作库(默认)。
Create a project that uses this library with its own package name and app name. 创建一个使用此库及其自己的程序包名称和应用程序名称的项目。 Add to it the same drawables (names) but branded (different content).
向其添加相同的可绘制图形(名称),但带有品牌(不同的内容)。 These drawables will override those of the library!
这些可绘制对象将覆盖库中的那些可绘制对象!
Remember to add activities and all application components and permissions to the new manifest. 请记住将活动以及所有应用程序组件和权限添加到新清单。
为此,您需要创建另一个Android项目,并使用ant将所有必需的资源复制到该项目并构建apk文件。
Try gradle with flavours and build type. 尝试用各种口味调味并建立类型。 You can achieve different set of apk in one build.
您可以在一个版本中实现一组不同的apk。 Checkout http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
结帐http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.