I have an application with several build options. Variants are used to create versions of the same application for different companies. So, I have several different options that create different applications:
- 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 is my problem. I integrate Dropbox into my applications. The AndroidManifest.xml file must be changed for each option to include the corresponding application key (saved 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> <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 option should change the following line:
<data android:scheme="db-abcdef" />
to the corresponding value for each application variant. In other words, I need to replace part of the specified string based on the assembly option. 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 option before the text "db -".
I need to dynamically replace the variable part of the string (x value) "db-xxxxxx" with the string from my string file.
I think this can be done using gradle scripts, but I am a complete newb with gradle. HELP!
If you can help, please be very specific about what has been going on since I SUKKA to gradle files and scripts. Thanks in advance!