Error when install AdMob


#1

Everything was well, before I installed the nativescript-admob plugin (for google ads).

When I install it and try to run the command “tns run android”, the console throws this:

Error: more than one library with package name ‘com.google.android.gms.license’.

I have rode most of articles about this, but nothing … Any ideas?

By the way - I`m using NativeScript with Angular 2 & Typescript - if this matters.


#2

Do you perhaps have more than 1 plugin using google play services? If so, that may be the same problem & solution as reported here: https://github.com/EddyVerbruggen/nativescript-admob/pull/27


#3

I modified the include.gradle file in nativescript-admob/platforms/android to this:

android {
productFlavors {
“admob” {
dimension “admob”
}
}
}

dependencies {
def googlePlayServicesVersion = project.hasProperty(‘googlePlayServicesVersion’) ? project.googlePlayServicesVersion : ‘+’
compile “com.google.android.gms:play-services-ads:$googlePlayServicesVersion”
}

… but this still not working. Another ideas?


#4

That’s not the correct approach actually. If you have the latest plugin version installed that should already be there, so make sure you update.

Then, in your app/App_Resources/Android/app.gradle file, add:

project.ext {
    googlePlayServicesVersion = "THE_VERSION"
}

Where THE_VERSION is the version specified by any other plugin that sets an explicit version for play services.


#5

I pasted this in the app.gradle file:

project.ext {
googlePlayServicesVersion = “^1.4.0”
}

“^1.4.0” is the version of the nativescript-admob plugin. Is this acceptable?

Now I am getting this error:

You have not accepted the license agreements of the following SDK components:
[SDK Patch Applier v4, Google Repository].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html


#6

No it’s not. You need to specify the play services version you want (9.8.0, for instance). Can you share your package.json so we can see all plugins you’re using?


#7

This is the package.json file

{
“description”: “NativeScript Application”,
“license”: "SEE LICENSE IN ",
“readme”: “NativeScript Application”,
“repository”: “”,
“nativescript”: {
“id”: “org.nativescript.AdmobP”,
“tns-android”: {
“version”: “3.3.1”
}
},
“dependencies”: {
@angular/animations”: “~4.4.1”,
@angular/common”: “~4.4.1”,
@angular/compiler”: “~4.4.1”,
@angular/core”: “~4.4.1”,
@angular/forms”: “~4.4.1”,
@angular/http”: “~4.4.1”,
@angular/platform-browser”: “~4.4.1”,
@angular/router”: “~4.4.1”,
“nativescript-admob”: “^1.4.0”,
“nativescript-angular”: “~4.4.0”,
“nativescript-theme-core”: “~1.0.2”,
“reflect-metadata”: “~0.1.8”,
“rxjs”: “~5.4.2”,
“tns-core-modules”: “~3.3.0”,
“zone.js”: “~0.8.2”
},
“devDependencies”: {
“babel-traverse”: “6.4.5”,
“babel-types”: “6.4.5”,
“babylon”: “6.4.5”,
“lazy”: “1.0.11”,
“nativescript-dev-typescript”: “~0.5.0”,
“typescript”: “~2.4.2”
}
}


#8

I changed the value to 9.8.0 - the example you said. Now it works!

Thank you very much, Eddy! I have just realized that this plugin is yours, congratulations!

By the way - I saw that my ads are showing up without implementing the app id anywhere, only the ad id.
Is this a problem? And … if it is, where I should place it?