4

I am trying to download a dependancy library mylibrary.aar from my gitlab repository via gradle. I understand that we dont have any closures/methods in gradle to directly get files from a http url.

Therefore am using ant's getmethod to download the library from gitlab.

Here is the code am using in my gradle file to get the library.

task downloadlib {

ant.get(src: 'https://my-git-link/mylibrary.aar', dest: 'libs', verbose: 'on')

}

dependencies {

compile(name: 'mylibrary', ext: 'aar')

}

Problem :

The files which I download via the ant's get method seems to be corrupted/does not go through the download process properly. Not sure what goes wrong. The library does not get compiled and the dependencies cannot be resolved. When I try to extract the aar it again extracts to cgpz file in my mac.I havent tried in windows though.

However, if I manually download the same aar file and reference it in the libs folder it works absolutely fine.

  1. Any idea why does this happen?
  2. Is there any other way to download a aar file from a gitlab server apart from ant.get?

Any help on this is much appreciated.

Note : I cannot use a locally built dependancy as all my libraries are on different repo and the project requirement mandates the same.Also, the code cannot be posted in github and thats the reason I did not choose jitpack

The same problem occurs for jar files as well.

DineshKumar
  • 1,599
  • 2
  • 16
  • 30
  • Possible duplicate of [Is it possible to declare git repository as dependency in android gradle?](https://stackoverflow.com/questions/18748436/is-it-possible-to-declare-git-repository-as-dependency-in-android-gradle) – Bertrand Martel May 21 '18 at 13:18
  • @BertrandMartel Appreciate your help. The answer provided in the other question is for people who have their code publicly in github. In my case the code cannot be shared. I have posted a solution. I hope that helps. – DineshKumar May 29 '18 at 03:12

2 Answers2

2

I dont think I have a direct solution for the problem as gradle does not have an api for this. Instead what I did was, created my own maven repository using jfrog's artifactory and hosted the libraries there so that all the developers can refer to the libraries from the internal artifactory.

The artifactory OSS version can be downloaded from here

I chose artifactory because it was much simpler and had a great UI. Most of all it did not require setting up a separate github repository for this purpose as the code cannot be shared outside the organization.

After setting up, your libraries can be accessed as below.

http://localhost:8081/artifactory.

A brief description of setting up an artifactory is provided here

After the libraries are hosted in your artifactory which can be located anywhere in your network, u or any other developer in your organization may access your libraries using the maven dependency manager in android.

I hope this helps.

DineshKumar
  • 1,599
  • 2
  • 16
  • 30
0

Do it like this example:

implementation 'com.quickblox:quickblox-android-sdk-core:2.5.2@aar'
implementation('com.quickblox:quickblox-android-sdk-chat:2.5.2@aar') {
    transitive = true
    }
Koustuv Ganguly
  • 897
  • 7
  • 21
  • This will work only if the library is hosted in `jcenter` or atleast a local `maven` repository. Thats not my question. My question is how do you get a library from a gitlab repo. – DineshKumar May 15 '18 at 06:35