1

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.

enter image description here

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

  1. Clean, Build, Rebuild
  2. Restart Android Studio
  3. Invalidate caches / Restart Android Studio
  4. Changing the project flavors & cleaning.
  5. 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?

Harsh4789
  • 677
  • 7
  • 17

1 Answers1

0

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.xml

 <activity
     android:name="com.google.android.gms.ads.AdActivity"
     android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
     android:exported="false"
     android:theme="@android:style/Theme.Translucent"
     tools:node="remove" />

 <activity
     android:name="com.google.android.gms.ads.purchase.InAppPurchaseActivity"
     android:theme="@style/Theme.IAPTheme"
     tools:node="remove" />

Hope it helps to someone.

Harsh4789
  • 677
  • 7
  • 17