Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish an Android library to a Maven repository to be used easily?

Tags:

android

maven

aar

I published my Android library (with dependencies) to an AWS S3 maven repository using this guide.

In a new project, I added the S3 bucket as a Maven repository, and I can successfully use it if I add the following to the new project's build.gradle file:

implementation ('com.mydomain:my_library:1.4:release@aar') {
    transitive=true
}

("transitive=true" is required so that the library's dependencies are included.)

However, I'd like for others to be able to use a simplified version of that like I've seen so many other libraries do:

implementation 'com.mydomain:my_library:1.4'

When I do that, I get "Cannot resolve symbol" errors in code and (of course) get "does not exist" errors when I try to build my project.

My library's POM file is shown below. Is there something I can change there so I can use the "simplified" implementation line above, or is there something else I can do?

Note: I tried replacing "< packaging>pom< /packaging>" with "< packaging>aar< /packaging>", invalidated the cache, and ran again, but the behavior was identical.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mydomain</groupId>
  <artifactId>my_library</artifactId>
  <version>1.4</version>
  <packaging>pom</packaging>
  <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>appcompat-v7</artifactId>
      <version>27.1.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support.constraint</groupId>
      <artifactId>constraint-layout</artifactId>
      <version>1.1.3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>design</artifactId>
      <version>27.1.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.reactivex.rxjava2</groupId>
      <artifactId>rxandroid</artifactId>
      <version>2.1.0</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.reactivex.rxjava2</groupId>
      <artifactId>rxjava</artifactId>
      <version>2.2.4</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.github.instacart.truetime-android</groupId>
      <artifactId>library-extension-rx</artifactId>
      <version>3.3</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.dagger</groupId>
      <artifactId>dagger-android</artifactId>
      <version>2.15</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.nostra13.universalimageloader</groupId>
      <artifactId>universal-image-loader</artifactId>
      <version>1.9.5</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.firebase</groupId>
      <artifactId>firebase-core</artifactId>
      <version>16.0.6</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.google.firebase</groupId>
      <artifactId>firebase-messaging</artifactId>
      <version>17.3.4</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>
like image 257
ScottyB Avatar asked Feb 18 '19 05:02

ScottyB


1 Answers

If your project happens to be hosted on Github consider using https://jitpack.io/ instead.

Jitpack allows you to very easily publish your libraries to gradle directly from Github.

While this answer does not directly answer your question, it does offer a valid and simpler alternative.

like image 64
Dean Wild Avatar answered Sep 29 '22 02:09

Dean Wild