Search code examples
android-studiomoduledependenciespom.xmlaar

Adding external dependecy to AAR file


I'm trying to add groundsdk dependency to my .aar module in android studio. So far I followed this thread and managed to get my pom file but I can't see any change in my .aar file.

Can anyone clarify where does this line goes?

implementation '${YOUR_GROUP_ID}:${YOUR_ARTIFACT_ID}:${YOUR_VERSION}'

Also, how do I know if my .aar contains my dependencies?

My library/build.gradle


dependencies {
    compileOnly files('libs/classes.jar')

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    // GroundSdk dependencies
    implementation 'com.parrot.drone.groundsdk:groundsdk:7.0.1'
    runtimeOnly 'com.parrot.drone.groundsdk:arsdkengine:7.0.1'

    //implementation 'com.test:anafi:1.0'
}
project.afterEvaluate {
    publishing {
        publications {
            library(MavenPublication) {
                groupId = 'com.test'
                //You can either define these here or get them from project conf elsewhere
                artifactId = 'anafi'
                version = 1.0
                artifact bundleReleaseAar //aar artifact you want to publish

                pom.withXml {
                    def dependenciesNode = asNode().appendNode('dependencies')
                    configurations.implementation.allDependencies.each {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
            }
        }
    }
}

Thank you all


Solution

  • OK so this wasn't the way to go about it for me.

    I, eventualy, tried other methods and found the answer.

    I posted my solution in this thread