Gradle项目运行报错Could not find method XXX及解决方案

Could not find method testCompile() for arguments

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.13.1'
}

原因是较新版的gradle将testCompile换成了testImplementation,因此换一下就好:

dependencies {
    testImplementation group: 'junit', name: 'junit', version: '4.13.1'

Could not find method compile() for arguments

dependencies {
    compile group: 'commons-io', name: 'commons-io', version: '2.6'
}

有人说报错原因是因为每一个compile声明之间应该用换行符隔开,可以先试试能不能解决问题。
在gradle官网输入关键字:
Gradle官网
在这里插入图片描述

会发现出现这类问题都是这种依赖配置写法在新版本中被移除了。
在这里插入图片描述

根据提示点进去会发现将compile关键字改一下就好:

dependencies {
    implementation group: 'commons-io', name: 'commons-io', version: '2.6'
}

遇到这类问题去官网查比在csdn查更容易解决问题。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值