gpt4 book ai didi

android - Gradle同步不会自动解析带有@aar批注的Android库项目依赖项

转载 作者:行者123 更新时间:2023-12-03 05:15:27 25 4
gpt4 key购买 nike

我创建了一个Android库项目,位于:https://github.com/dbotha/Android-Photo-Picker

照片选择器库项目本身具有多个依赖项:

// library build.gradle
dependencies {
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.squareup.picasso:picasso:2.5.2'
}

我已经在Maven Central上提供了该库项目,以便可以轻松将其作为依赖项添加到应用程序中:
// application build.gradle
dependencies {
compile 'ly.kite:photo-picker:1.1.2@aar'
}

但是问题是,当我将其作为依赖项添加到新的Android应用程序项目时,它崩溃了,因为它无法从库项目中找到Picasso依赖项:
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.squareup.picasso.Picasso" on path
只有当我将这种依赖关系明确添加到应用程序build.gradle时,事情才起作用。

我的库POM文件 dependencies看起来正确: https://repo1.maven.org/maven2/ly/kite/photo-picker/1.1.2/photo-picker-1.1.2.pom

所以我很好奇,是否包含我的照片选择器库作为依赖项的应用程序总是也需要显式添加所有照片选择器库的依赖项吗?

最佳答案

您正在使用@aar表示法。
这意味着您只想下载aar Artifact ,而没有依赖项。
您可以检查documentation的这一部分:
检查1.4.1.2. Artifact only notation部分:

An artifact only notation creates a module dependency which downloads only the artifact file with the specified extension. Existing module descriptors are ignored.



如果要下载依赖项,请使用 @aar表示法,应添加 transitive=true

我希望省略@aar应该可以。

关于android - Gradle同步不会自动解析带有@aar批注的Android库项目依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32204339/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com