I have an app with multiple build variants. The variants are used to build versions of the same app for different companies. So, I have several different variants that build different apps:
- com.acme.app1
- com.schmoe.app2
- com.yop.app3
- etc...
The build.gradle file handles this very well:
productFlavors {
app1 {
applicationId "com.acme.app1"
}
app2 {
applicationId "com.schmoe.app2"
}
app3 {
applicationId "com.yop.app3"
}
}
Here's my problem. I am integrating Dropbox into my apps. The AndroidManifest.xml file must be changed for each variant to include the appropriate app key (stored in my string file). Dropbox has the following addition to the manifest file:
<activity
android:name="com.dropbox.client2.android.AuthActivity"
android:launchMode="singleTask"
android:configChanges="orientation|keyboard">
<intent-filter>
<!-- Change this to be db- followed by your app key -->
<data android:scheme="db-abcdef" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
Each build variant needs to change the following line:
<data android:scheme="db-abcdef" />
to the appropriate value for each app variant. In other words, I need to replace part of the above string based on the build variant. For instance
App1
<data android:scheme="db-111111" />
App2
<data android:scheme="db-222222" />
App3
<data android:scheme="db-333333" />
The line is the same for each variant up to the text "db-".
What I need is to dynamically replace the variable portion of the string (the x values) "db-xxxxxx" with a string from my string file.
I think this can be done with gradle scripts but I'm a complete newb with gradle. HELP!
If you can help, please be very specific about what goes where since I SUCK at gradle files and scripting. Thanks in advance!