Can I use the AdMob SDK banner as a dependency in my maven android project?

I just switch my build process to using maven, I canโ€™t find the dependency for AdMob on the maven repository site, how to configure it manually?

For instance:

<dependencies> <dependency> <groupId>com.google.android</groupId> <artifactId>android</artifactId> <version>2.2.1</version> <scope>provided</scope> </dependency> </dependencies> 
+4
source share
2 answers

An easy way to do this is to have the lib library in the source tree and use it:

 ... <dependency> <groupId>some_admob_groupid</groupId> <artifactId>admob</artifactId> <version>admob_version</version> <scope>system</scope> <systemPath>${basedir}/lib/admob.jar</systemPath> </dependency> ... 

Of course, you need to change groupId, artifactId, version and systemPath to suit your needs, but this approach allows you to have a local .jar in your pom.xml as a dependency, without installing it in your repository.

+2
source

I saw that this did not yet have the answer that I originally wanted to find, therefore, although it is a little older, here for future Googlers:

Download the jar from https://developers.google.com/mobile-ads-sdk/download

Put this in your pom.xml (with the appropriate version of the course):

 <dependency> <groupId>com.admob.android</groupId> <artifactId>ads</artifactId> <version>6.4.1</version> </dependency> 

And then run this in your shell, again with the corresponding version name / jar:

 mvn install:install-file -Dfile=GoogleAdMobAdsSdk-6.4.1.jar -Dversion=6.4.1 -DartifactId=ads -DgroupId=com.admob.android -DgeneratePom=true -Dpackaging=jar 

Keep in mind that the above command has a version that needs to be changed in two places - once in the file name and once in the -Dversion parameter.

It might also be a good idea to include the latest version of the library in your project and have something like the following in your pom.xml above the dependency, as this is not the step that you will probably remember if you should google it;)

 <!-- If you just set up your dev system and the following dependency gives you an error, run these commands: cd project-root mvn install:install-file -Dfile=libs/GoogleAdMobAdsSdk-6.4.1.jar -Dversion=6.4.1 -DartifactId=ads -DgroupId=com.admob.android -DgeneratePom=true -Dpackaging=jar --> 
+1
source

Source: https://habr.com/ru/post/1341693/


All Articles