[博客迁移][Android] 依赖ConstraintLayout报错,Could not find *****,Failed to resolve:****

2,277 阅读1分钟

from 依赖ConstraintLayout报错,Could not find *****,Failed to resolve:*****


这篇文章为您讲述依赖ConstraintLayout报错,Could not find *****,Failed to resolve:*****的相关介绍,具体代码请看下文

ConstraintLayout 约束布局,Android Studio2.2中新增功能之一,2.3版本的Android Studio支持在约束布局中使用 Chains(链接) 和 Ratio(比例) 。

使用ConstraintLayout需要在gradle中添加依赖:compile'com.android.support.constraint:constraint-layout:1.0.0-beta5'

clone别人的项目时发现报错误:

Failed to resolve:com.android.support.constraint:constraint-layout:1.0.0-beta5 或 Could not find com.android.support.constraint:constraint-layout:1.0.0-beta5

错误原因:AndroidStudio更新到2.3版本,ConstraintLayout跟着更新到了1.0.1,所以报错了

解决办法:

  • 工具栏上选择 Tools --> Android -->SDK Manager 切换到SDK Tools选项

  • 在右下角处勾选 Show Package Details

  • 在Support Repository下的ConstraintLayout for Android 和 Solver for ConstraintLayout 中选中自己需要的版本(gradle中依赖的版本)

  • 点OK,再同步gradle就可以了。