We have two different flavor dimensions like in this example and we want to dynamically generate applicationId like
com.company.apple
instead this script will generate an applicationId of
null.company.apple
I believe this is because the function at the bottom iterates over the full productFlavor list and not the combined list.
flavorDimensions "product", "license"
productFlavors.all {
ext.scheme = null
ext.scheme_tail = ""
ext.kind = null
ext.license = null
}
productFlavors {
apple {
dimension "product"
kind = "apple"
scheme = "companyapple"
}
orange {
dimension "product"
scheme = "companyorange"
kind = "orange"
}
kiwi {
dimension "product"
scheme = "companykiwi"
kind = "kiwi"
}
com {
dimension "license"
license = "com"
scheme_tail = ''
}
eu {
dimension "license"
license = "eu"
scheme_tail = "eu"
}
uk {
dimension "license"
license = "uk"
scheme_tail = "uk"
}
}
productFlavors.all {
applicationId license + ".company." + kind
ext.fileProvider = applicationId + ".fileprovider"
manifestPlaceholders = [scheme: "$scheme$scheme_tail", fileProvider: "$fileProvider"]
buildConfigField("String", "FILE_PROVIDER", "\"$fileProvider\"")
buildConfigField("String", "SCHEME", "\"$scheme$scheme_tail\"")
buildConfigField("String", "KIND", "\"$kind\"")
buildConfigField("String", "LICENSE", "\"$license\"")
}
How can I iterate over the combined list to build my buildConfig fields and applicationIds?
The manifestPlaceholders are consumed like this:
<activity android:name=".FruitViewerActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="${scheme}" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="${fileProvider}"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
Thanks, Rory