Transitive dependencies not resolved for aar library using gradle

那年仲夏 提交于 2019-11-26 15:08:04

I have solved my problem by setting transitive attribute for my aar dependency:

compile ('com.somepackage:LIBRARY_NAME:1.0.0@aar'){
    transitive=true
}
user3070402

you should not use "@aar", if use "@" is become "Artifact only notation", if you want to use "@" and want have dependence transitive, you should add "transitive=true"

Try this if you are using aar locally:

compile(project(:your-library-name)) {
    transitive=true
}

Simply adding @aar at the end of the dependency is what worked for me.

dependencies {
    implementation 'org.videolan.vlc:libvlc:3.0.13@aar'
}

For me complete publishing solution looks like this:


apply plugin: 'com.github.dcendents.android-maven'

group = GROUP
version = VERSION

// you could move it to env variable or property
def publishFlavorless = true
def firstTask = null

android.libraryVariants.all { variant ->

    if (variant.name.toLowerCase().contains("debug")) {
        // Workaround for https://github.com/gradle/gradle/issues/1487
        if (publishFlavorless && firstTask == null) {
            def bundleTask = tasks["bundle${variant.name.capitalize()}Aar"]
            firstTask = bundleTask
            artifacts {
                archives(firstTask.archivePath) {
                    builtBy firstTask
                    name = project.name
                }
            }
        }
        return
    }

    def bundleTask = tasks["bundle${variant.name.capitalize()}Aar"]

    artifacts {
        archives(bundleTask.archivePath) {
            classifier variant.flavorName
            builtBy bundleTask
            name = project.name
        }
    }
}

install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom.project {
            name POM_NAME
            artifactId POM_ARTIFACT_ID
            // For aar it is equal to 'aar' with jar transitive dependencies won't work
            packaging POM_PACKAGING
            description POM_DESCRIPTION
        }
    }
}

The transitive = true block is required as well ...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!