简体   繁体   English

Build.gradle无法解析com.android.support

[英]Build.gradle Failed to resolve com.android.support

I was working on my project yesterday and everything was going fine. 昨天我正在做我的项目,一切都很好。 Today when I opened it up, it failed to build. 今天,当我打开它时,它无法构建。 I don't understand this because I did not touch my dependencies at all yesterday. 我不明白这一点,因为昨天我根本没有碰过我的依赖项。 I did all the things I could think of. 我做了我能想到的所有事情。

I rebuilt the project multiple times,cleaned it, invalidate cache / restart , sync project with gradle files and it still doesn't work. 我多次重建项目,将其清理,使缓存/重启无效,使用gradle文件同步项目,但仍然无法正常工作。 Please help! 请帮忙!

我的应用程序级别build.gradle 的build.gradle 错误

在build.gradle中,用implementation更改每个compile (在第一张图片中)

you have used two time dependency of below. 您使用了以下两个时间依赖性。 remove one of them. 删除其中之一。

 implementation 'com.android.support:appcompat-v7:28.0.0'

I can't really tell what the proble is but I can give you a sequence of steps that can help you troubleshoot. 我无法真正说出问题所在,但可以为您提供一系列步骤,以帮助您进行故障排除。

First , change all compile to implementation . 首先 ,将所有compile更改为implementation Although this is not the reason why your gradle is failing to resolve, it can still give you insight into the problem. 尽管这不是您的问题无法解决的原因,但仍然可以使您深入了解问题。

Next , remove redundant dependencies. 接下来 ,删除冗余依赖项。 Remove dependencies if you don't need them. 如果不需要它们,请删除它们。 This would help lighten the load so that you have a narrow list of dependencies to debug. 这将有助于减轻负载,从而使调试的依赖项列表变窄。 Also, I couldn't help but notice that you have two support libraries. 另外,我不禁注意到您有两个支持库。 Remove one. 删除一个。

Next , look at the part of your build.gradle file that is highlighted (for example, the classpath). 接下来 ,查看build.gradle文件中突出显示的部分(例如,classpath)。 These are warnings/recommendations. 这些是警告/建议。 If you hover around them, you'd see suggestions from android studio telling you what you could do better. 如果您将鼠标悬停在它们周围,则会看到android studio的建议,告诉您您可以做得更好。 Follow all of these instructions to the letter. 请按照所有这些说明进行操作。 Most of them would advise you to make the versions of all your dependency tally. 他们中的大多数会建议您制作所有依赖项的版本。 Obey. 遵守。

Finally , after doing all of this, I'm pretty sure the problem would have been solved. 最后 ,完成所有这些操作后,我很确定问题会得到解决。 You can simply clean the project after all of this. 完成所有这些操作后,您只需清除项目即可。

I really hope this works for you.. Merry coding! 我真的希望这对您有用。

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

相关问题 Build.gradle:无法解决:com.android.support - Build.gradle: Failed to resolve: com.android.support Gradle构建失败并出现错误无法解决:com.android.support - Gradle build failed with error Failed to resolve: com.android.support gradle构建失败错误:无法解决:com.android.support:cardview-v7:24.0.1和)无法解决:com.android.support:appcompat-v7:24.0.1 - gradle build fail Error: Failed to resolve: com.android.support:cardview-v7:24.0.1 and ) Failed to resolve: com.android.support:appcompat-v7:24.0.1 Gradle项目同步失败(无法解决:com.android.support:appcompat-v7:26.1.1) - Gradle project sync failed ( Failed to resolve: com.android.support:appcompat-v7:26.1.1) Android:build.gradle错误(“无法解决”) - Android: build.gradle error (“Failed to resolve”) 无法解决:构建gradle后com.android.support,但仍可以安装我的应用 - Failed to resolve: com.android.support after building gradle but my app can still be installed Gradle和Android:无法解析依赖项com.android.support - Gradle and Android: Could not resolve dependencies com.android.support 无法解析com.android.support:support-v4:23.2.1 - failed to resolve com.android.support:support-v4:23.2.1 无法解析:com.android.support:support-v4:23.0.0 - Failed to resolve: com.android.support:support-v4:23.0.0 无法解决:com.android.support:support-compat:27.2.0 - Failed to resolve: com.android.support:support-compat:27.2.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM