A while back I remember reading an article talking about how Gradle was being updated to be smart about flavor dependencies and not downloading or processing dependencies not required for the flavor being compiled. At the time I remember thinking, “Oh, that might be nice. Then F-Droid can get rid of all those sed
commands in their metadata files.” I recently went looking for that article and couldn’t fine it. Neither could I easily find similar information in Gradle’s release notes. However, the most recent build of Privacy Browser indicates that such is the case.
First, a little bit of background. Privacy Browser has two flavors, standard
and free
. Standard is the flavor built for F-Droid. Free is feature-identical except for the addition of a banner ad across the bottom of the screen. When I first released Privacy Browser Free I used Google’s AdMob with a dependency similar to the following.
freeCompile 'com.google.android.gms:play-services-ads:8.4.0'
This required adding the following line to the metadata:
prebuild: sed -i -e '/play-services/d' build.gradle
After a while, Google started recommending that apps using AdMob switch to the Firebase backend, which I did with the 1.12 release. This caused my build on F-Droid to fail until the prebuild line was updated to be:
prebuild: sed -i -e '/firebase/d' build.gradle
However, recently Google started recommending that apps that only use AdMob ads and not any of the other features of Firebase switch back to using the play-services-ads dependency, which I did with the 3.7 release with the following freeImplementation line:
freeImplementation 'com.google.android.gms:play-services-ads:19.8.0'
I was intending to update the metadata file when the build failed after it was populated for the 3.7 release. But, the build succeeded. This leads me to believe that in many cases the sed
lines that exist in the metadata files are now no longer needed and can be removed.