Custom implementation of specfic files using productFlavors in Android

103 Views Asked by At
I added a new flavor in my Build.Gradle :: 
    productFlavors {
            pro{
                applicationIdSuffix ".pro" //newpackagename=com.example1.android.pro
               } 
                   }
    My android app structure:
       Project      
       |
        `-- res
             |-- drawable
                      |-- logo.png
       |
        `-- src
            |
             `-- com
                 |-- example1
                        |--- android
                                    |-- db
                                         |-- DatabaseHelper.java
                                         |-- DBObject.java
                                    |-- pro //created new package manually 
                                    |-- AppProperties.java
                                    |-- AndroidTimerFactory.java

But I want to start customizing the application for "Pro" and want to add a new logo.png for that package. How can I do that? where to add the new png image since it lies outside the src folder.

2

There are 2 best solutions below

6
On

Typically you would have folder under src for each product flavor and could then, in your example, store your flavor specific resources under src/pro/res

0
On

Even if it lies outside the src folder it doesn't matter.Gradle will make sure that it is overriden while merging resources. Simply put the png file in src/pro/res/drawable/logo.png