Skip to content

2. Creating A Company App

krtonga edited this page Jun 19, 2018 · 1 revision

LAST UPDATED: June 13, 2018


An Overview

MajiFix uses app flavors to create branded versions of an app. This means the core of the MajiFix Android Application can be found in the main directory (app/src/main). This code in this directory is shared between all MajiFix based applications.

Company specific and company branded information (company name, logos, payment information, the server endpoint, etc) are not in the core of the MajiFix application. Instead these resources are placed in app flavors. App flavors are defined in the app level build.gradle file, and flavor specific assets have their own flavor directory, for example: app/src/MYCOMPANY.

This pattern is used so that if a bug is fixed in the core code, it can be fixed in all company instances with a simple git pull, with minimal code clashes.

Creating an App for your Company

Download Main Repository

If you haven't yet downloaded the main android repo, please do that now. We use a version control system called Git which we use to keep track of changes, and work with a remote team. More information on Git can be found here.

To download the MajiFix repository, open a terminal and do the following:

# navigate to the directory where you wish to download the repository
cd MY_DIRECTORY

# clone the repository
git clone ''

Add a Company Flavor

Now it's time to create your own an app flavor:

  1. Add a new flavor to the app/build.gradle file. Replace <COMPANY_NAME> with your company variant name:

    android {
    
        productFlavors {
            mycompany {
                dimension COMPANY
                
                applicationIdSuffix ".<COMPANY_NAME>"
                versionNameSuffix "-<COMPANY_NAME>"
                versionCode 1
                versionName "1.0"
                
                resValue "string", "content_provider", "com.github.codetanzania.<COMPANY_NAME>.provider"
                ext {
                    buildconfigs = [
                            [type: 'String', name: 'END_POINT', values: [debug: '<DEBUG_ENDPOINT>', release: '<RELEASE_ENDPOINT>']],
                            [type: 'int', name: 'MAJIFIX_TOKEN', values: [debug: '<DEBUG_TOKEN>', release: '<RELEASE_TOKEN>']]
                    ]
                }
            }
    
  2. Add a flavor directory. Directory structure (in Project view) should now look like:

        - dawasco-v2
           - app
           - src
              - androidTest
              - main
              - <COMPANY_NAME>
              - test
    

    Note: Name of directory must match name defined in build.gradle file.

Customize Your App

  1. Add launcher icon. The launcher icon is the image shown on the Android Home Screen.

    1. Generate the image in the image editor of your choice.
    2. To import to Android Studio Import an Image Asset (File > New > Image Asset)
    3. In the Configuration Dialog, select the image you have created.
    4. Click Next.
    5. Fix config
  2. Add company logos.

  3. Add company assets (contact us, payment info, etc).

  4. Add custom strings. It is required to override the following strings:

Building your app

To build your custom flavor, click the Build Variants tab on the lower right side of Android Studio. Update the app BuildVariant to be MYCOMPANYDebug. Build app normally, for example: press the green play button.

Clone this wiki locally