Home > Blockchain >  How to host an .aar library and securely access it from gradle project?
How to host an .aar library and securely access it from gradle project?

Time:09-14

I have a library (which we will name "test.aar" here), and i need to implement it inside an Android Project.

However, hosting it on Maven, as far as i know, is Open Source, and anyone can access it.

I am looking for a way to host the "test.aar" library somewhere with a "private mode".

What i mean by "private mode" is actually some credentials or tokens/keys to allow the access to "test.aar".

i would like to maybe use it like that inside build.gradle with credentials:

dependencies {
  implementation "io.test-lib:test-lib:1.0.0"
}

PS : I have to do it remotely and ideally free (can pay if needed but not too expensive).

CodePudding user response:

In your build.gradle file you can use

implementation project(':mylibrary')

if you have the library set up as a subproject in your workspace. If you just have a binary, you can use

implementation fileTree(dir: 'path_to_file', include: ['*.aar'])

Either of these just require it to exist locally on the filesystem.

CodePudding user response:

I once used some "secret SDK" and the provider of this SDK hoste it in jfrog. https://jfrog.com/ The usage looks like this, in user's top level build.gradle:

allprojects {
repositories {
    maven {
        url "https://some_sdk_maker.jfrog.io/artifactory/secret-android-sdk"
        credentials {
            username = "username"
            password = "password"
        }
    }

    apply plugin: "com.jfrog.artifactory"
}

Then user must add the "implementation" string in the module's buid.gradle file. So only those who have the username and pass will be able to use your library.

  • Related