I am having two product flavors in the project (1) free (2) pro
I am including google ads library only to the free product flavor as below
freeCompile 'com.google.android.gms:play-services-ads:11.4.2'
Now I want to replace it with another ad library. I am trying to remove this dependency but it doesn't remove the library completely and gives me an error as below. Hence it doesn't let me build the project.
The screenshot is of AndroidManifest.xml from the app\build\intermediates\manifests\full\free\debug. Also I have not manually added these two activities (com.google.android.gms.ads.AdActivity & com.google.android.gms.ads.purchase.InAppPurchaseActivity) to the main AndroidManifest.xml.
What I have tried to remove these two activities from AndroidManifest.xml is
- Clean, Build, Rebuild
- Restart Android Studio
- Invalidate caches / Restart Android Studio
- Changing the project flavors & cleaning.
- Removing the dependency from the Android Studio 'Project Structure'
But nothing seems to be working. How can I get rid of these errors and build my project?

After a day long hassle, I managed to fix it using this official Android guildeline - Merge Multiple Manifest Files
tools:node="remove"did the trick.I have manually removed those two activities that are the part of google sdk. Here is what I have added to the main
AndroidManifest.xmlHope it helps to someone.