Cannot resolve symbol 'R',Failed to resolve: constraint-layout

1、当在github上下载demo项目在Android studio启动时,提示Cannot resolve symbol 'R'。虽然提示错误,但是运行项目并没有问题

原因是gradle版本高于本地Android studio的gradle版本

classpath 'com.android.tools.build:gradle:3.3.1'

改为

classpath 'com.android.tools.build:gradle:3.2.1'

同步即可

 

2、如果是依赖包类,报错,如Cannot resolve symbol 'xxxx'

解决方法1:

隐藏依赖——>同步——>放出依赖——>同步

解决方法2:

如果是fragment类无法导入

替代默认依赖即可

完整默认依赖:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'

或者更换appcompat版本

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

 

最近在Android Studio中导入工程时,编译出错,提示如下:

Error:(55, 13) Failed to resolve: com.android.support.constraint:constraint-layout:1.0.2

Install Repository and sync project
 

打开SDK。看看已下载版本

 

依赖版本。改为已安装版本

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值