My current Android projects has a lot of flavors, and each flavor has different keystore to sign with. As a result it has very long build.gradle project file. As each flavor need defining separate singningConfig and defining flavor signing on release buildType. After reading couple of articles, i end up with this solution:
Change Snippet Background Color
1. Modify signingConfigs to fit with difference signing keystore for each flavour like example below
// create 2 or more difference keystore.
signingConfigs {
configFirst {
keyAlias KEY_ALIAS_MY
keyPassword STORE_PASSWORD_MY
storeFile file('../keystore_my.jks')
storePassword KEY_PASSWORD_MY
}
configSecond {
keyAlias KEY_ALIAS_SG
keyPassword STORE_PASSWORD_SG
storeFile file('../keystore_sg.jks')
storePassword KEY_PASSWORD_SG
}
.....
debug{
}
}
2. This is example of flavour. based on this example, only SGPROD and MYPROD i assign it to their own keystore. That's all as easy 123.. :D
productFlavors{
SGPROD{
applicationId "com.mobile.sg"
buildConfigField 'String', 'URL_LINK',SG_URL_PROD;
buildConfigField 'String', 'URL_API',SG_API_PROD;
//assign this flavour with signingConfigs configSecond
signingConfig signingConfigs.configSecond
}
SGDEV{
applicationId "com.mobile.sg.dev"
buildConfigField 'String', 'URL_LINK',SG_URL_DEBUG;
buildConfigField 'String', 'URL_API',SG_API_DEBUG;
}
MYPROD{
applicationId "com.mobile.my"
buildConfigField 'String', 'URL_LINK',MY_URL_PROD;
buildConfigField 'String', 'URL_API',MY_API_PROD;
//assign this flavour with signingConfigs configFirst
signingConfig signingConfigs.configFirst
}
MYDEV{
applicationId "com.mobile.my.dev"
buildConfigField 'String', 'URL_LINK',MY_URL_DEBUG;
buildConfigField 'String', 'URL_API',MY_API_DEBUG;
}
}
No comments:
Post a Comment