4

I'm just switching my build process to use maven, I can't find the dependency for AdMob on the maven repository site, how can I configure it manually?

Such as :

<dependencies>
        <dependency>
            <groupId>com.google.android</groupId>
            <artifactId>android</artifactId>
            <version>2.2.1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
Jimmy
  • 16,123
  • 39
  • 133
  • 213

2 Answers2

2

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

...
<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 the groupId, artifactId, version and systemPath to suit your needs but this approach lets you have a local .jar in your pom.xml as a dependency without installing it to your repository.

Jeremy Whitlock
  • 3,808
  • 26
  • 16
  • I'd prefer to install it to my local repo so I can use in other projects, how can I do that? – Jimmy Feb 28 '11 at 19:37
  • Just remember that all developers/computers that you use to do development will need to go through this step where as my suggestion lets you avoid this: http://maven.apache.org/plugins/maven-install-plugin/usage.html – Jeremy Whitlock Feb 28 '11 at 20:16
  • Sadly, this doesn't seem to work, see http://stackoverflow.com/questions/4960954/android-admob-and-maven – futlib Jun 04 '11 at 05:25
1

I saw this still didn't have the answer OP originally wanted, so despite it being a bit older, here's 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 course):

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

And then run this on your shell, again with the appropriate version/jar name:

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

Mind you that the above command has the version that you need to change in two places - once in the filename, 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 isn't a step you are likely to remember if you had to 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

-->
Torque
  • 3,319
  • 2
  • 27
  • 39