简体   繁体   中英

Replace an XML file for each flavour in android

I am trying to integrate Braze into my application for push notification. Braze need us to create a braze.xml file inside src/main/res/values where we add the API key and other braze related stuff(here is the documentation ).

Now I need to differentiate prod and qa environment meaning they will have 2 different API keys.

I was wondering how I could use a different braze.xml for different flavours.

I found this :

sourceSets {
    main {
         java {
            srcDirs = ['src']
         }
    }

    test {
        java {
            srcDirs = ['test']
        }
    }
}

and I was wondering how to use it to replace my braze.xml for different build variants.

You can create multiple source sets for different flavours of your project. By default there is only main/ source set created by studio which contains the common code that will be shared across different variants. For more details on how to create and maintain the source sets check official documentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM