47

Is there any reason that the Android toolchain and development jars aren't in the Maven CEntral repository? Is it really just that no one has done it? or are there some licensing issues? I mean it's all open source right? (except for the Google APIs).

I'm tempted to put it up myself in a non central repo, but I just want to be sure that someone else hasn't done it yet and that I won't be corresponding or playing telephone tag with any lawyers as a result.

shemnon
  • 5,318
  • 4
  • 28
  • 37

5 Answers5

42

Google blocked it. From this link:

The Android artifacts have been built and published to the Maven repository through the efforts of the Android for Maven project. Google prevented the official Android jars from being uploaded to Maven, so the, third party, Android for Maven project was started to provide an API compatible Android artifact that could be uploaded to the Maven repository. There are now artifacts for each major Android version available in the Maven repository. These are not functional, however, and only provide stubbed implementations of the API. All methods in all classes throw a runtime exception. Because an Android app runs on a device, it will never use these libraries for execution, but the API compatibility allows an app to be compiled as if it were the real library.

thomaux
  • 19,133
  • 10
  • 76
  • 103
  • 2
    @shemnon - Yes, that would be the short answer :) – thomaux Apr 01 '11 at 06:42
  • @Blundell does that solve the problem of deploying to Maven Central? – Adam Nov 26 '13 at 03:05
  • @adam You can deploy them locally so you don't have to worry about central yes. – Blundell Nov 26 '13 at 09:08
  • @Blundell the point is being able to deploy Android libraries to central so that others may use them. Currently you can do so for libraries that depend on APIs up to 4.2 because people have uploaded stripped versions of the older Android APIs. – Adam Dec 05 '13 at 00:31
  • @Adam you could also make your own repo, like we did: https://github.com/novoda/public-mvn-repo – Blundell Dec 06 '13 at 13:41
24

Google now has an official maven repository announced at Google IO 2017.

buildscript {
    repositories {
        maven {
          // Google Maven Repository
          url 'https://maven.google.com'
        }
    }
    ...
}

What's New in Android Support Library (Google I/O '17)
https://youtu.be/V6-roIeNUY0?t=3m34s

What's New in Android Development Tools (Google I/O '17)
https://youtu.be/Hx_rwS1NTiI?t=20m05s

Google's Maven repository
https://developer.android.com/studio/build/dependencies.html#google-maven

Migrate to the New Plugin
https://developer.android.com/studio/preview/features/new-android-plugin-migration.html

Ryan R
  • 8,342
  • 15
  • 84
  • 111
9

I found a better solution, using the common libraries delivered by SDK, I just used Android Home as repository in the pom.xml.

 <repositories>
    <repository>
        <id>com.android.support</id>
        <url>file://${env.ANDROID_HOME}/extras/android/m2repository</url>
    </repository>
</repositories>

does work for me now.

Marco
  • 160
  • 2
  • 10
5

It's possible to use the ANDROID_HOME jars by specifying a system-<dependency> with <systemPath>:

<properties>
    <android.platform>21</android.platform>
</properties>
<dependencies>
    <dependency>
        <groupId>com.google.android</groupId>
        <artifactId>android</artifactId>
        <version>${android.platform}</version>
        <scope>system</scope>
        <systemPath>${env.ANDROID_HOME}/platforms/android-${android.platform}/android.jar</systemPath>
    </dependency>
</dependencies>
Johannes Brodwall
  • 7,673
  • 5
  • 34
  • 28
2

I think they are in maven central:

http://mvnrepository.com/artifact/com.google.android/android

It doesn't look like it has 3.0 yet, but it does have quite a few older revisions. You can build android projects with maven with the help of maven-android-plugin.

Erich Douglass
  • 51,744
  • 11
  • 75
  • 60
  • 1
    That's just the platfor jars, stuff for runtime. I'm looking for stuff like sdklib.jar that as the APKPackager in it. (package com.android.sdklib.build). – shemnon Mar 10 '11 at 01:24
  • Also, step two of the maven-android-plugins says install the google android SDK. I really think maven should be able to download the internet for me. why should I have to do it myself? – shemnon Mar 10 '11 at 01:25
  • Ah, my mistake. I recently mavenized a few Android projects, so I had that in the front of my mind :) – Erich Douglass Mar 10 '11 at 16:08