您的位置:首页 > 移动开发 > Android开发

Android Studio编译异常解决记录

2017-06-05 10:27 239 查看

1. Gradle Sync Issues



错误信息如下:

Error:Unable to find method ‘com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V’.

Possible causes for this unexpected error include:
Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

按错误提示,多次点击【Re-download dependencies and sync project (requires network)】发觉都无任何效果;点击【Stop Gradle build processes (requires restart)】,在Android Studio重启几次之后也无效果。

此时怀疑有可能是Gradle版本问题,查看该程序的Gradle版本为:

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


查看本机发现并不包含此版本的Gradle,因此将其修改为本机已经下载的Gradle版本:

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


重新编译,错误变成了:



该问题应该是因为本机没有安装appcompat-v7:25.3.1版本造成的,可采用如下两种解决方案:

①按照提示安装新版本的包;

②将该版本修改为本机已安装的包版本,如25.2.0;

经修改过后,程序可以编译通过,问题顺利解决。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐