Skip to content Skip to sidebar Skip to footer

How To Serve Aar Files Using Jitpack

I want to publish an android library I've been working on using jitpack. But I want to do it without publishing the source-code. I don't want jitpack to build it, I uploaded the ou

Solution 1:

I actually solved this recently (sample here), mainly via a tutorial here.

The steps:

  1. Prepare the aar file. This you can do using the "assembleRelease" gradle task. You should consider adding Proguard rules too. Example here of some rules that you might want to add.

  2. Create a new Github repository, and upload the aar file there.

  3. Put 2 new files in the repository. One is jitpack.yml (very important to have 2 spaces before the "-", as opposed to what's written on the article) :

install: 
  - FILE="-Dfile=mylibrary-release.aar" 
  - mvn install:install-file $FILE -DgroupId=com.lb.sdktest -DartifactId=test -Dversion=1.0 -Dpackaging=aar -DgeneratePom=true
  1. Another is pom.xml :
<?xml version="1.0" encoding="iso-8859-1"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
             http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.lb.sdktest</groupId><artifactId>test</artifactId><version>1.0</version></project>

You should change the "com.lb.sdktest" and "test" according to what you wish, but I think it gets ignored anyway as it's changed automatically on Jitpack according to where it exists (in my case of the sample it changed to implementation 'com.github.AndroidDeveloperLB:SdkTest:7' )

  1. On Github, create a new release, go to Jitpack, paste the URL there (example here of what I did), wait a bit for the release to appear, and press "GET" button.

That's it. You will get the new instructions for SDK-users of how to use your new dependency!

EDIT: while this is working fine, I've found some important issues that if someone knows how to fix, it will be very appreciated:

  1. What's the meaning of those extra files? Why does it seem the values there are ignored?

  2. I've noticed that the SDK-user will have to add all dependencies the aar is using. How come? I've read somewhere that for maven plugin, it is the one that generates the pom file, which adds dependencies too. But how can I use it properly for Jitpack? I tried to use it, and indeed it generated a POM file which seem to have the dependencies. I tried to follow all the possible tips and guidelines, but still failed to use it properly. Wrote about this here.

  3. Even though I've added many KotlinDocs (JavaDocs but for Kotlin), those get completely removed on the way to generate the AAR file. I have no idea how to preserve them in any way. Choosing to generate it manually (via the IDE there is a way to generate JavaDocs), it didn't succeed as it said there are no Java files. How can I generate those and make them available for SDK-users?

  4. As it became obfuscated, I've noticed a weird thing: It removed some important parts of Retrofit classes that I've made. I've written about this here, and I just wonder if that's the best way to solve it, or there is a better way.

Post a Comment for "How To Serve Aar Files Using Jitpack"