Aparna
Aparna

Reputation: 845

In Android how to add Admob when googleplay services is already used

In the gradle dependencies I have included the following

compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services-ads:8.3.0'

But it gives the following error.

Error:Execution failed for task ':app:processDebugResources'.

Error: more than one library with package name 'com.google.android.gms' You can temporarily disable this error with android.enforceUniquePackageName=false However, this is temporary and will be enforced in 1.0

How can it be fixed

Upvotes: 2

Views: 87

Answers (1)

Cory Charlton
Cory Charlton

Reputation: 8938

The first line of compile 'com.google.android.gms:play-services:7.5.0' already includes the ads API (source):

Selectively compiling APIs into your executable

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:

compile 'com.google.android.gms:play-services:8.3.0'

with these lines:

compile 'com.google.android.gms:play-services-fitness:8.3.0'

compile 'com.google.android.gms:play-services-wearable:8.3.0'

As described it's probably a better idea to only include the APIs you need. The link above provides a table of available APIs.

Upvotes: 2

Related Questions