Skip to content

Configure Build Variants with Different Configuration File

By providing different sap_mobile_services.json files, you can configure build variants to allow your app to connect to different landscapes, while still using the same code base. For example, you might want to build one version of your app to connect to a Neo landscape, and another version to connect to a Cloud Foundry landscape.

Sample Build Variants Configuration

  1. Define productFlavors in the module-level build.gradle file inside the android block.

    android {
        ...
        defaultConfig {...}
        buildTypes {
            debug{...}
            release{...}
        }
    
        productFlavors {
            cf {
                applicationIdSuffix ".cf"
            }
            neo {
            }
        }
    }
    
  2. Create two folders named cf and neo under /app/src.

  3. Put the corresponding sap_mobile_services.json file under the raw resources folders, app/src/neo/res/raw/ and app/src/cf/res/raw/.
  4. Remove the existing application configuration file, app/src/main/res/raw/sap_mobile_services.json.
  5. After creating and configuring the product flavors, click Sync Now in the notification bar. After the sync completes, Gradle automatically creates build variants based on your product flavors.
  6. Select the cf or neo build variant to select the corresponding sap_mobile_services.json file for the app to connect to the respective landscape.

Info

Refer to the Developer Guide for detailed information on build variants and product flavors.


Last update: September 29, 2020