简体   繁体   English

如何使用相同的源代码但使用不同的资源构建不同的APK

[英]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.

相关问题 使用不同的源代码创建多个APK - Creating multiple APKs with different source code 如何在Maven和Eclipse中使用不同的依赖版本两次构建相同的源代码? - How to build same source code twice with different dependency version, in both Maven and Eclipse? 使用Eclipse在同一项目中发布不同的APK? - Publish different APKs with the same project with Eclipse? Sbt脚本以及不同的资源和源目录 - Sbt script and different resources and source directories 可以从相同的源代码构建产生功能不同的可执行文件吗? - Can builds from the same source code yield functionally different executables? 为什么热点在同一源代码中使用不同的程序集 styles? - Why does hotspot use different assembly styles in same source code? 多个ClassLoader如何从不同位置加载同名资源? - How to load resources with the same name from different locations in multiple ClassLoader? 如何从类路径中的不同jar加载一个相同的命名资源? - How to load one of same named resources from different jars in a classpath? 针对不同的依赖项集构建相同代码的推荐方法是什么? - What is the recommended way to build the same code against different sets of dependencies? 不同的颜色,相同的代码 - Different colors, same code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM