Using aar library results in no dependencies using api in Gradle 4.x

When I create an application with a * .aar file instead of a module with Gradle 4.x and following document relatively implements api, I expect that using api, the included aar file contains all the dependencies, but it did not.

When you do

git clone https://github.com/hannesa2/aar_dependency
./gradlew clean assembleDebug

means

dependencies {
    api project(':mylibrary')

It works correctly.

But when I use the insted lib module, the previous generated * .aar file as a dependency

 dependencies {
    api 'com.example.my.mylibrary:mylibrary-debug@aar'

(in the demo application just do it)

git checkout with_aar
./gradlew clean assembleDebug

I ran into this

: app: transformClassesWithDesugarForDebug "main" java.lang.TypeNotPresentException: io.reactivex.ObservableTransformer         at sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:85)         at sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:63)         at sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:41)          java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1067)         at com.google.devtools.build.android.desugar.LambdaDesugaring $InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:399)         at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn( )          org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn( )

, aar Maven Nexus, demo-repo, , . Maven .

- , ?

+3
1

. Android O Gradle 4.x, api

dependencies {
    api 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    api "io.reactivex.rxjava2:rxandroid:$versions.libs.rxAndroid"

-

publishing {
    publications {
        mipartner(MavenPublication) {
            groupId '...'
            artifactId '..'
            version 1.0
            artifact "$buildDir/outputs/aar/myLib-release.aar"

            //generate pom nodes for dependencies
            pom.withXml {
                def dependenciesNode = asNode().appendNode('dependencies')
                configurations.compile.allDependencies.each { dependency ->
                    def dependencyNode = dependenciesNode.appendNode('dependency')
                    dependencyNode.appendNode('groupId', dependency.group)
                    dependencyNode.appendNode('artifactId', dependency.name)
                    dependencyNode.appendNode('version', dependency.version)
                }
            }
        }
    }

    repositories{
        maven {
            url "https://some.url.com"
        }
    }
}

, *.pom, , api pom!

configurations.api.allDependencies.each { dependency ->

aar

dependencies {
    api "com.mylib.net:mylib:1.0"
+7

All Articles