简体   繁体   English

Android Gradle 找不到远程 AAR

[英]Android Gradle not finding remote AAR

I was working with Gradle v5.4 and Android Gradle Plugin v3.5.2 , and had no problems!我正在使用Gradle v5.4Android Gradle Plugin v3.5.2 ,没有问题!

I have a remote Artifactory repository where I upload .aar files that are needed in my project.我有一个远程 Artifactory 存储库,我可以在其中上传项目所需的.aar文件。

When I updated to Gradle v6.5 and Android Gradle Plugin v4.0.1 those .aar files are no longer downloaded.当我更新到Gradle v6.5Android Gradle Plugin v4.0.1 时,不再下载这些.aar文件。

This is how I add those dependencies:这就是我添加这些依赖项的方式:

implementation "ar.com.sebasira:some-library:1.0.0@aar"

This was working just fine before the upgrade.这在升级前工作得很好。

In the logs I can see that AndroidStudio looks for it in this location:在日志中,我可以看到 AndroidStudio 在这个位置寻找它:

https://myrepo.com.ar/ar/com/sebasira/some-library/1.0.0/some-library-1.0.0.pom https://myrepo.com.ar/ar/com/sebasira/some-library/1.0.0/some-library-1.0.0.pom

If I put that URL in the browser, indeed there's nothing to be found, but if I change the last part (the extension) to .aar I can download the artifact.如果我将该 URL 放在浏览器中,确实找不到任何内容,但是如果我将最后一部分(扩展名)更改为.aar我可以下载该工件。

I thought that adding @aar was to instruct Gradle to look for .aar file but it seems not to be working.我认为添加@aar是为了指示 Gradle 查找.aar文件,但它似乎不起作用。

I've also try adding the dependency like in this other way with no luck.我也尝试以其他方式添加依赖项,但没有运气。

implementation group: 'ar.com.sebasira', name: 'some-library', version: '1.0.0', ext: 'aar'

I've found out that since Gradle v6.0 onwards, Gradle assumes that if no .pom file is present in the remote repository is because the artifact does not exists, so it does not look for it by default.我发现从Gradle v6.0开始,Gradle 假设远程存储库中不存在.pom文件是因为工件不存在,因此默认情况下它不会查找它。 According to release notes :根据发行说明

If Gradle fails to locate the metadata file ( .pom or ivy.xml ) of a module in a repository defined in the repositories { } section, it now assumes that the module does not exist in that repository.如果 Gradle 无法在repositories { }部分定义的repositories { }找到模块的元数据文件( .pomivy.xml ),则它现在假定该模块不存在于该存储库中。

... ...

You can opt into the old behavior for selected repositories by adding the artifact() metadata source.您可以通过添加artifact()元数据源为所选存储库选择旧行为。

So the solution is to add that to repository in question, like this:因此,解决方案是将其添加到相关存储库中,如下所示:

repositories {
    maven {
        url 'the-repo-url'
        metadataSources {
            artifact()
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM