问题:
最近公司让我对接一键免密登陆功能,客户端开发也需要熟悉,用Android Studio打开项目后报错,内容如下:
ERROR: Unsupported method: AndroidProject.getVariantNames().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
错误原因翻译:
错误:不支持的方法:AndroidProject.GetVariantNames()。
连接到的Gradle版本不支持该方法。
要解决此问题,您可以更改/升级所连接的Gradle的目标版本。
或者,您可以忽略这个异常并从模型中读取其他信息。
解决方法:
- 修改工程目录下的 build.gradle 文件
classpath "com.android.tools.build:gradle:3.3.2" // 版本为你Android Studio 版本号对应
- 工程 ./gradle/wrapper/gradle-wrapper.properties 中,看下地址链接
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
- gradle sync 一下即可;