4

I am facing an issue where I am not able to generate the desired resource files. In my project setup I have defined certain values in resource files(keys.xml) that are different between flavors(amazon, googlePlay). The problem mainly occurs because the keys are also different between the live/qa builds.

So the final keys I would like to have are:

  • amazonPaidQa -> keys from 'src/amazon/res/values/keys.xml'
  • amazonPaidLive -> keys from 'src/amazonPaid/res/values/keys.xml' (not working as this requires me to define the keys file in 'src/amazonPaidLive')

My question is if it is possible to define resources in 'interim' build variants like the above mentioned 'amazonPaid' so that I would not have to duplicate that file between all possible live build variants(amazonPaidLive, amazonFreeLive). Or maybe someone has a better suggestion how to approach this problem?

build.gradle definitions

buildTypes {
    qa {
        //config
    }

    live {
        //config
    }
}

flavorGroups "market", "client"

productFlavors {
    //define the market flavors
    amazon {
        flavorGroup "market"
    }

    googlePlay {
        flavorGroup "market"
    }

    //define the client flavors
    free {
        flavorGroup "client"
        packageName "com.example.free"
    }

    paid {
        flavorGroup "client"
        packageName "com.example.paid"
    }
}

The folder structure is the following:

- src/main
-- AndroidManifest.xml
-- res/values/keys.xml
- src/live
- src/qa
- src/amazon
-- res/values/keys.xml
- src/googlePlay
-- res/values/keys.xml
- src/paid
- src/free

Android Manifest snippet

<application>
    ...
    <meta-data android:name="app_id" value="@string/app_id" />
</application>
Rehr
  • 41
  • 3
  • I know that I was not able to make default localization files for each flavor in `Gradle` when a particular string did not exist for a flavor so I had to repeat them for each language. I don't know if that's changed. You can check my SO on the topic [here](http://stackoverflow.com/questions/23396860/localization-within-product-flavors). I don't know if this will be much help. – craned Jul 16 '15 at 21:44

0 Answers0