Android-Could not find method implementation() for arguments

当AndroidStudio加载工程的时候:报以下错误:

详细错误:

Could not find method implementation() for arguments [file collection] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

《Android-Could not find method implementation() for arguments》

 

在工程的app/build.gradle中查看:

《Android-Could not find method implementation() for arguments》

 

修改工程的app/build.gradle,compile -修改成–> implementation

【解决此问题的第一步:】

《Android-Could not find method implementation() for arguments》

 

 

查看工程的-build.gradle:

《Android-Could not find method implementation() for arguments》

 

 打开一个,在当前电脑,当前AndroidStudio正常编译运行OK的工程的build.gradle文件:

copy  classpath ‘com.android.tools.build:gradle:3.2.1’

《Android-Could not find method implementation() for arguments》

 

【解决此问题的第二步:】

修改工程的-build.gradle,为 classpath ‘com.android.tools.build:gradle:3.2.1’

《Android-Could not find method implementation() for arguments》

 

 

成功解决:

《Android-Could not find method implementation() for arguments》

 

 

 

总结解决细节:解决这种类型的错误,一定一定要仔细分析报错的详情(例如:翻译报错详情),特别要注意的是,报错详情中 有没有提示版本相关的信息,非常重要;

 

总结解决步骤:

为什么要修改 compile 为 implementation:

    implementation是gradle版本3.0之后才支持的,出现该问题代表你的gradle版本过低。

解决步骤:

  第一步:将implementation改为compile

  第二步:升级build.gradle文件中的Gradle版本

 

 

 

 

 

 

 

点赞