Could not find method implementation() for arguments [directory 'libs']

喜欢ヅ旅行 2021-12-21 12:47 372阅读 0赞

git 下载一个项目,编译报错如下ERROR: Could not find method implementation() for arguments [directory ‘libs’] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Open File

建议安装as时,新建一个项目,作为参考。每次下载各个版本的gradle 以及compileSdkVersion版本的Android api。

同步代码后,编译一直出错,其实是因为git主用的gradle编译版本比我本地(3.4.1)低了,人家最近没更新吧,然后自己Google了一波

classpath ‘com.android.tools.build:gradle:2.3.2’

改成

classpath ‘com.android.tools.build:gradle:3.4.1’


新版本已经可以使用implementation、api了, 代替了 compile ,testImplementation 代替了testCompile,androidTestImplementation 代替 androidTestCompile 。

例如gradle中:

compile fileTree(dir: ‘libs’, include: [‘*.jar’]);

改成

implementation fileTree(dir: ‘libs’, include: [‘*.jar’]);

作为开发人员,我们要关注自己编译器版本更新的利弊,多去用他,了解关注。书到用时方恨少,纸上得来终觉浅。祝你好运!

发表评论

表情:
评论列表 (有 0 条评论,372人围观)

还没有评论,来说两句吧...

相关阅读