开发者

Brandable Android Application

开发者 https://www.devze.com 2023-02-11 09:48 出处:网络
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).

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.

  1. Customers of clients will use this app.
  2. You could be a customer of more than one client, but we cannot show the user any kind of list of clients.
  3. Clients cannot share a single app.
  4. 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, 开发者_JAVA技巧what is the best way to build an easily brandable application with as little strain on the developer's sanity as possible?


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.


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.


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.


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):

productFlavors {
    vanilla {
        applicationId "com.example.multiflavorapp"
    }

    strawberry {
        applicationId "com.example.multiflavorapp.strawberry"
    }
}

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号