1

I do have a structure like below. I wanna use different manifestPlaceHolder like this, projectXTest, projectXDev, projectXProd all use different manifestPlaceHolder while projectYTest,Prod,Dev uses the same manifestPlaceHolder. What I can do besides putting that values to string.xml for all different flavors

android {
    buildTypes{
        debug{
            // Some debug setup
        }
        release{
            // Some release setup
        }
    }


   flavorDimensions "project" , "default"
    productFlavors {
        projectX{
         dimension 'project'
           }
       
        projectY{
          dimension 'project'
           }

        Test{
          dimension 'default'
           }
        Dev{
          dimension 'default'
           }
        Prod{
          dimension 'default'
           }
    }
}

1 Answers1

0

Since I could find an out of this. I followed this steps. I hope, If somebody find her/himself in this situation, this helps.

Firstly

Put a manifest to desired flavors directory, for my example I've put android manifest to src/projectY and src/projectX

Beware these not to be full manifest. It should be layered like below

<manifest>
  <application>
    <activity>
        android:name=".x.loginActivity"
        tools:node="merge" // this is must
        // your flavor spesific code
    </activity>
  </application>
</manifest>

Secondly

Delete your code to minimum in main XML. What i mean that manifest you've created in src/flavor will be merged with main one. so that delete what you want to seperate and leave what you want to used common in main.

Thirdly

Give different manifestPlaceholder name if you need to seperate prod,dev and staging. For example,

src/projectX/manifest.xml

 <activity>
    .
    .
    android:host='${projectXHost}'
    .
    </activity>

src/projectY/manifest.xml

<activity>
.
.
android:host='${projectYHost}'
.
</activity>

in gradle

productFlavors{

 prod {
   manifestPlaceholders = [projectXHost : 'xxx' , projectYHost : 'yyy']
}

}

Since this is my first answer, I'm sorry with layout and expressions. I hope you can understand what I mean. Have a good day