Create android library through maven publish which is having a dependency on AAR file

90 views Asked by At

I am publishing my custom library to maven local and using it in my project. However recently my library is dependant on a AAR dependency and I am unable to bundle it with my custom library.

I have tried almost everything available on stackoverflow. When I create the library using publishToMavenRepository, it does not have required AAR within it and my project is unable to resolve the dependency.

I have used the following plugins to help me achieve it.

classpath 'com.github.kezong:fat-aar:1.3.8'
        classpath "com.mobbeel.plugin:fat-aar:2.0.1"

and then I created a separate_file and added

configurations.maybeCreate("default")
artifacts.add("default", file('myaar.aar'))

and then I have used the following in the gradle

 api project(':separate_file')
or
embed project(':separate_file')

The library works when tested independently, however when I publish using publishToMavenRepository and the add the maven dependancy in the my project it says Failed to resolve :separate_file

My maven publish gradle looks like this

project.afterEvaluate {
    def groupId = 'com.ss'
    def artifactId ='mylib'
    def versionName = '1.0.0'

    publishing {
        publications {
            MyLibrary(MavenPublication) {
                from components.release
                setGroupId groupId
                setArtifactId artifactId
                version versionName
            }
        }
        repositories {
            maven {
                url "artifacts"
            }
        }
    }
}

Note: My custom library works fine when tested independently without publishing and using it in other project as maven dependancy. Issue is only faced when having AAR dependencies

0

There are 0 answers