久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Gradle 4.x 中使用 aar 庫導致缺少使用 api 的依賴

Use an aar library cause missing dependencies using api in Gradle 4.x(在 Gradle 4.x 中使用 aar 庫導致缺少使用 api 的依賴項)
本文介紹了在 Gradle 4.x 中使用 aar 庫導致缺少使用 api 的依賴項的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

當我使用 *.aar 文件而不是使用 Gradle 4.x 的模塊并遵循 docu 關于 implementsapi,我希望使用 api 包含的 aar 文件包括所有依賴項,但沒有.

When I build an app with a *.aar file instead of the module with Gradle 4.x and following the docu concerning implements and api, I expect using api the included aar file has all dependencies included, but it hasn't.

當你這樣做時

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

表示

dependencies {
    api project(':mylibrary')

它工作正常.

但是當我使用 lib-module 的 insted 之前生成的 *.aar 文件作為依賴項時

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

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

(在 demo app 中即可)

git checkout with_aar
./gradlew clean assembleDebug

我遇到了這個

任務 :app:transformClassesWithDesugarForDebug線程main"中的異常 java.lang.TypeNotPresentException:類型 io.reactivex.ObservableTransformer 不存在在 sun.invoke.util.BytecodeDescriptor.parseSig(BytecodeDescriptor.java:85)在 sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:63)在 sun.invoke.util.BytecodeDescriptor.parseMethod(BytecodeDescriptor.java:41)在 java.lang.invoke.MethodType.fromMethodDescriptorString(MethodType.java:1067)在 com.google.devtools.build.android.desugar.LambdaDesugaring$InvokedynamicRewriter.visitInvokeDynamicInsn(LambdaDesugaring.java:399)在 org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(未知來源)在 org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(未知來源)

Task :app:transformClassesWithDesugarForDebug Exception in thread "main" java.lang.TypeNotPresentException: Type io.reactivex.ObservableTransformer not present 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) at 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(Unknown Source) at org.objectweb.asm.MethodVisitor.visitInvokeDynamicInsn(Unknown Source)

因為我通常在將 aar 工件上傳到我們公司 Maven Nexus 時遇到這個問題,所以我創建了這個 demo-repo 以準確顯示問題所在.在演示應用程序或使用 Maven 中,我看到了同樣的問題.

Because I ordinary run into this with uploading the aar artifacts into our company Maven Nexus, I created this demo-repo to show exactly what's wrong. In demo app or using Maven I see the same issue.

有人知道我做錯了嗎?

推薦答案

我能夠解決它.主要問題是使用 api

I was able to solve it. The main issue was Android O with Gradle 4.x using api

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

大多數答案都與這樣的事情有關

Most answers are concerning something like this

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 中!

but here in the resulting *.pom there are no dependencies included, after change this line to api the dependencies are included in deployed pom !

configurations.api.allDependencies.each { dependency ->

在此之后您可以輕松使用 aar 文件

after this you can easily consume the aar file

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

這篇關于在 Gradle 4.x 中使用 aar 庫導致缺少使用 api 的依賴項的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

IncompatibleClassChangeError after updating to Android Build Tools 25.1.6 GCM / FCM(更新到 Android Build Tools 25.1.6 GCM/FCM 后出現 IncompatibleClassChangeError)
How to get current flavor in gradle(如何在 gradle 中獲取當前風味)
How to fix quot;unexpected element lt;queriesgt; found in lt;manifestgt;quot; error?(如何修復“意外元素lt;查詢gt;在“清單中找到錯誤?)
Multi flavor app based on multi flavor library in Android Gradle(基于 Android Gradle 中多風味庫的多風味應用)
Android dependency has different version for the compile and runtime(Android 依賴在編譯和運行時有不同的版本)
Transitive dependencies for local aar library(本地 aar 庫的傳遞依賴)
主站蜘蛛池模板: 成人在线一区二区三区 | 99国产视频 | 亚欧午夜| 日日操日日舔 | 亚洲国产一区二区视频 | 午夜电影一区二区 | 99资源| 91文字幕巨乱亚洲香蕉 | 亚洲综合色视频在线观看 | 久久久久国产一级毛片 | 日韩波多野结衣 | 欧美激情在线精品一区二区三区 | 综合第一页 | 国产精品一区在线 | 亚洲国产欧美一区二区三区久久 | 久久久久亚洲精品 | 亚洲人成人一区二区在线观看 | 黄色免费在线网址 | 免费观看一级毛片 | 中文字幕免费视频 | 国产精品久久久久久久久免费桃花 | 免费观看视频www | 欧美一区二区三区久久精品 | 高清一区二区 | 亚洲免费在线观看视频 | 久久国产免费 | 日韩一区和二区 | 欧美日韩专区 | 亚洲国产aⅴ成人精品无吗 亚洲精品久久久一区二区三区 | 欧美日韩成人网 | 欧美久久久久 | 黑人巨大精品欧美黑白配亚洲 | 秋霞电影一区二区 | 在线观看免费观看在线91 | 91视频免费在观看 | 中文字幕成人 | 丝袜天堂| 久久久av | 色噜噜狠狠色综合中国 | 日韩av一区二区在线观看 | 一级大片 |