可品牌化的 Android 应用程序
我们为多个客户提供服务。我们想要提供的一项功能是 Android 应用程序,它允许客户自定义应用程序品牌(图标、徽标、名称等)。
这里有一些规定。
- 客户的客户将使用此应用程序。
- 您可能是多个客户的客户,但我们无法向用户显示任何类型的客户列表。
- 客户端无法共享单个应用程序。
- 即使功能相同,每个客户的应用程序也必须能够看起来不同。
是的,我知道以这种方式构建它是 PITA,但我们的客户不希望其他客户的客户知道他们也是我们的客户。
那么,构建易于品牌化的应用程序并尽可能减少对开发人员理智的压力的最佳方法是什么?
We service multiple clients. One feature we want to offer is an android application which allows the client to custom brand the application (icons, logos, names, etc).
Here are a few stipulations.
- Customers of clients will use this app.
- You could be a customer of more than one client, but we cannot show the user any kind of list of clients.
- Clients cannot share a single app.
- The app must be able to look different per client, even though the functionality is the same
Yes, I know it's a PITA to build it this way, but our clients don't want customers of other clients to know they are also our client.
So, what is the best way to build an easily brandable application with as little strain on the developer's sanity as possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
为每个版本的应用程序保留一个单独的 res/ 文件夹。为每个图标、徽标和字符串指定相同的名称,但为每个客户端定制内容,只需将该 res 文件夹放入构建中即可为每个客户端构建不同的 .apk。我认为您不能让自定义限定符为此工作,而只需制作一个 .apk - 无论如何,这都会将每个客户的自定义图片和字符串捆绑到每个人的应用程序中。
Keep a separate res/ folder for each version of the app. Give every icon, logo and String the same name but tailor the content for each client, and build a different .apk for each by simply dropping that res folder into the build. I don't think you can make custom qualifiers work for this and just make a single .apk - and this would in any case bundle every client's custom pictures and Strings in to everyone's application.
我将从开发一个用于全局重命名的脚本开始,因为无论如何您都需要它(可以使用 find、xargs 和 sed 相当简单地完成)
您将需要用于对资源进行自定义的工具,这可能是SDK及Eclipse 插件
也许您可以创建某种扩展 Eclipse 插件的向导。
或者,通过大量工作但更容易使用,您可以独立执行一些操作来驱动必要的命令行工具来构建生成的包。
I would start by developing a script for a global re-name, since you'll need that anyway (can be done fairly simply with find, xargs and sed)
You'll need tools for making the customizations to resources, that could be the SDK & Eclipse plug-in
Perhaps you could create some kind of wizard extending the Eclipse plug-in.
Or with a lot of work but easier usage, you could do something stand alone that drives the necessary command line tools to build the generated package.
您可以执行@Jems所说的操作,或者(假设应用程序与服务器通信)将“逻辑”放在服务器端。
第一次运行应用程序时,服务器将向您发送本地存储的与客户端相对应的资源。
这种方法的问题:第一次您可能需要下载大量内容...
优点:您只需更改一个属性字符串,说明哪个是服务器,或者登录到服务器以了解它必须发送的内容布局,而无需部署具有不同资源的另一个应用程序。
这实际上取决于您是否想支持服务器端的布局更改。
You can do what @Jems said or (presuming that the app comunicates with a server) put the "logic" on the server side.
The first time you run the application the server will send you the resources corresponding to your client that you store locally.
Problems with this approach: The first time you may have to download a load of stuff...
Advantages: You just have to change a properties string saying which is the server, or the login to the server to know what it has to send changing the layout without having to deploy another app with different resources.
It really depends if you want to support layout changes on server side.
使用 gradle 的构建时解决方案可以通过 ProductFlavors 功能来实现,如 http://blog.robustastudio.com/mobile-development/android/building-multiple-editions-of-android-app-gradle/
风味(又名客户品牌)可以在按照以下方式构建 build.gradle 文件(此处使用不同的包名称将每个品牌 apk 部署为单独的应用程序):
然后可以将品牌的特定 android 资源(而不是 src/main/res 目录)放置到 src/vanilla/res 或src/strawberry/res 目录(在本例中香草和草莓是品牌)。请注意,使用productFlavors功能,gradle不会合并资产,只是简单地替换文件,而不了解特定的res子目录。
在构建过程中,gradle 将构建变体创建为构建类型(调试、发布)和 ProductFlavor 的组合,更多信息请参见 http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Type -产品风味构建变体。
Build time solution using gradle could be achieved with productFlavors feature, described in http://blog.robustastudio.com/mobile-development/android/building-multiple-editions-of-android-app-gradle/
Flavors (aka customer brands) could be defined in build.gradle file in the following way (different package names are here to deploy each branded apk as separate application):
Specific android resources for brand could be then placed (instead of src/main/res directory) into src/vanilla/res or src/strawberry/res directories (in this case vanilla and strawberry are the brands). Please be aware that using productFlavors feature, gradle does no merging of assets, only simple replacing files without any knowledge about specific res subdirectories.
During building proces gradle creates build variants as combination of build type (debug,release) and productFlavor, more at http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Type-Product-Flavor-Build-Variant.