Android 私有 Maven 仓库中库的子依赖项未被项目下载
Android library's sub dependencies in private Maven repo is not downloaded by project
Android 库托管在我工作的公司的私有 Maven Artifactory 存储库中。
该库使用 okhttp 作为依赖项之一。
在应用程序项目中,我这样导入这个库:
compile 'com.domain.artifact:myartifact:1.0.0@aar'
库已导入,但是当我在库中调用 API 时,应用程序因缺少 okhttp 类.
而崩溃并出现 ClassNotFoundException
执行gradle命令打印依赖项显示应用程序项目没有下载任何库的依赖项(包括okhttp)
+--- com.domain.artifact:myartifact:1.0.0
\--- com.android.support:appcompat-v7:25.0.1
\--- com.android.support:support-v4:25.0.1
+--- com.android.support:support-compat:25.0.1
| \--- com.android.support:support-annotations:25.0.1
+--- com.android.support:support-media-compat:25.0.1
| \--- com.android.support:support-compat:25.0.1 (*)
+--- com.android.support:support-core-utils:25.0.1
| \--- com.android.support:support-compat:25.0.1 (*)
\--- com.android.support:support-core-ui:25.0.1
如何确保库的依赖项也被成功下载或发布?
====== 附加信息 =======
库使用"maven-publish"插件发布,在gradle脚本中使用"pom.withXml"添加依赖,okhttp在库的POM文件中。
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
您正在使用 @aar
表示法。
这意味着您只想下载不包含所有嵌套依赖项的 aar 工件。
您可以检查documentation的这一部分:
检查 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 库托管在我工作的公司的私有 Maven Artifactory 存储库中。 该库使用 okhttp 作为依赖项之一。
在应用程序项目中,我这样导入这个库:
compile 'com.domain.artifact:myartifact:1.0.0@aar'
库已导入,但是当我在库中调用 API 时,应用程序因缺少 okhttp 类.
而崩溃并出现 ClassNotFoundException执行gradle命令打印依赖项显示应用程序项目没有下载任何库的依赖项(包括okhttp)
+--- com.domain.artifact:myartifact:1.0.0
\--- com.android.support:appcompat-v7:25.0.1
\--- com.android.support:support-v4:25.0.1
+--- com.android.support:support-compat:25.0.1
| \--- com.android.support:support-annotations:25.0.1
+--- com.android.support:support-media-compat:25.0.1
| \--- com.android.support:support-compat:25.0.1 (*)
+--- com.android.support:support-core-utils:25.0.1
| \--- com.android.support:support-compat:25.0.1 (*)
\--- com.android.support:support-core-ui:25.0.1
如何确保库的依赖项也被成功下载或发布?
====== 附加信息 =======
库使用"maven-publish"插件发布,在gradle脚本中使用"pom.withXml"添加依赖,okhttp在库的POM文件中。
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.4.1</version>
</dependency>
您正在使用 @aar
表示法。
这意味着您只想下载不包含所有嵌套依赖项的 aar 工件。
您可以检查documentation的这一部分:
检查 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 它应该有效。