Android Stutio 3.0 - Gradle sync failed
(url:http://blog.csdn.net/column/details/zsl-androidstudio.html)
1. 项目老是报错:
Gradle sync failed: Argument for @NotNull parameter 'key' of com/android/tools/idea/gradle/project/model/ide/android/ModelCache.computeIfAbsent must not be null
Gradle project sync failed. pliease fix your project and try again
solution, Gradle 设置其到本地(我android-studio安装在"C:/android-studio"):
File->Setting->Build,Execution,Deployment->Gradle:
1. Use locla gradle distribution
C:/android-studio/gradle/gradle-4.1-milestone-1
不行的话, 见 第4点 , 此处设置 恢复默认, 更改 Gradle 版本
2.修改LogCat的颜色
- File->Settings 或Ctrl + Alt +S
- 找到 Editor -> Colors &Fonts -> Android Logcat 或在上面的搜索框中输入Logcat
- 点中Verbose , Info, Debug等选项,然后在后面将Use Inberited attributes 去掉勾选
- 再将 Foreground 前的复选框选上,就可以双击后面的框框去选择颜色了
- Apply–>OK
Log级别 色值
VERBOSE BBBBBB
DEBUG 63AABB
INFO 211DD5
WARN BBBB23
ERROR FF0006
ASSERT 8F0005
(url:http://blog.csdn.net/yy1300326388/article/details/45825123)
logcat中打印位置,可以点击跳转 Git:https://github.com/orhanobut/logger
(url:http://blog.csdn.net/yy1300326388/article/details/45825343)
4.AndroidStudio中使用Aliyun Maven
Aliyun Maven地址:http://maven.aliyun.com
在项目级别的build.gradle中添加如下Maven地址:
buildscript {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
jcenter()
}
}
4.Error:Unable to find method 'com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V'.
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.2.0'
重新编译,错误变成了:
该问题应该是因为本机没有安装appcompat-v7:25.3.1版本造成的,可采用如下两种解决方案:
①按照提示安装新版本的包;
②将该版本修改为本机已安装的包版本,如25.2.0;
经修改过后,程序可以编译通过,问题顺利解决。
??????
上面问号中间是 网上搜到比较近似的, 我的实际情况是:
项目的 build.gradle 配置
buildscript {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
allprojects {
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle 配置为 2.2.0
加 buildscript 和 allprojects 的 maven 配置是为了 下载资源 使用国内的 maven 镜像, 速度快
之后更改 gradle/wrapper/gradle-wrapper.properties (不手动改,也应该有错误提示, 点击自动 Fix )
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
然后编译通过!!
< Kotlin > Android Studio3.0 Kotlin工程问题集 http://blog.csdn.net/poorkick/article/details/72599929
Android开发错误——Android Studio中遇到过的错误问题与解决方案汇总 http://blog.csdn.net/qq_30379689/article/details/52089633
Android Stutio 3.0 - Gradle sync failed的更多相关文章
- Android Studio 首坑 Gradle sync failed: Cause: error in opening zip file 的错误
前言 今天安装Android studio 2.3.1时发生了一个错误,安装完成后创建第一个Hello World项目是报错.经过这个百度后,结果没有一个靠谱的.将拆解经过记录一下. 环境: 操作系统 ...
- AS中加载gradle时出现Gradle sync failed: Could not find com.android.tools.build:gradle.的错误
时间:2019/12/7 这次接着整理加载gradle时出现的错误 出现的错误: Gradle sync failed: Could not find com.android.tools.build: ...
- Android Studio中Gradle sync failed
问题:Android Studio中更新同步Gradle 失败 Gradle sync failed: Could not find com.android.tools.build:gradle:3. ...
- Android:Gradle sync failed: Another 'refresh project' task is currently running for the project
android studio 克隆项目后,重新导入后显示Gradle sync failed: Another 'refresh project' task is currently running ...
- Gradle sync failed: Could not find method android() for arguments 错误的解决办法
这个问题本质上是Android-gradle的一个使用限制. 对应的英文文档android_tool文档 如果你的App包含了多个Android模块, 应该尽量避免给每个模块手动指定编译SDK版本. ...
- Gradle sync failed: Gradle version 2.2 is required. Current version is 2.10.
Gradle sync failed: Gradle version 2.2 is required. Current version is 2.10. If using the gradle wra ...
- Gradle sync failed: failed to find Build Tools revision 21.1.2
从github上下载了一个开源项目到Android Studio 出现以下问题: 下午2:56:05 Gradle sync started下午3:00:11 Gradle sync failed: ...
- Gradle sync failed: Cannot set the value of read-only property 'outputFile'
错误 Gradle sync failed: Cannot set the value of read-only property 'outputFile' 原因 gradle打包,自定义apk名称代 ...
- Gradle sync failed: Cause: org.gradle.logging.StyledTextOutput$Style Consult IDE log for more details
环境 Android studio 3.0 导入开源中国: ... dependencies { //noinspection GradleDependency classpath 'com.andr ...
随机推荐
- php的底层原理
PHP说简单,但是要精通也不是一件简单的事.我们除了会使用之外,还得知道它底层的工作原理. PHP是一种适用于web开发的动态语言.具体点说,就是一个用C语言实现包含大量组件的软件框架.更狭义点看,可 ...
- iOracle实战笔记(第五天)
导读 今天的主要内容:维护数据的完整性.索引.管理Oracle的权限和角色. 一.维护数据库的数据的完整性 数据完整性用于确保数据库数据遵从一定的商业规则和逻辑规则.在Oracle中,数据完整性可以使 ...
- 原生 JS 实现一个瀑布流插件
更好的阅读体验,点击 原文地址 瀑布流布局中的图片有一个核心特点 -- 等宽不定等高,瀑布流布局在国内网网站都有一定规模的使用,比如pinterest.花瓣网等等.那么接下来就基于这个特点开始瀑布流探 ...
- HTTP常用方法
GET : 获取资源 get方法用来请求访问已被URI识别的资源. 请求 GET /index.html HTTP/1.1 HOST:www.baidu.com 响应 返回index.html的页面资 ...
- Centos7-两台Centos机器间复制文件
我又两台Centos机器,一台192.168.1.1:另一台192.168.1.2 现在在将192.168.1.1上的一个文件复制到192.168.1.2.登陆到192.168.1.1然后运行命令 命 ...
- 一步步使用BMC Atrium Orchestrator Vmware Infrastructure Event Monitor
本教程将一步步演示怎么使用BMC Atrium Orchestrator (BAO) Vmware Infrastructure Event Monitor来监控VSphere Webservice的 ...
- TDD最佳实践
这里就先目前阶段,整理一份TDD的最佳实践,在之后的Xunit测试整理中,这份实践会越来越长,对于这份核心在写测试的时候应该时刻注意. 1,在软件开发领域中,从来没有这样的事情:少数的几行代码对大量的 ...
- 【Python3之迭代器,生成器】
一.可迭代对象和迭代器 1.迭代的概念 上一次输出的结果为下一次输入的初始值,重复的过程称为迭代,每次重复即一次迭代,并且每次迭代的结果是下一次迭代的初始值 注:循环不是迭代 while True: ...
- wampserver 的Apache启动错误提示:The requested URL / was not found on this server.
打开localhost显示以下错误 原因:之前我配置了虚拟主机,所以服务器是从虚拟环境访问的,localhost也就访问不到 解决方法:打开httpd.conf配置文件,将Include conf/e ...
- 编译原理-NFA构造DFA
本题摘自北邮的编译原理与技术. 首先,根据此图构造状态转换表 表中第一列第一行表示从第一个符号B通过任意个空转换能到达的节点,Ia表示由此行的状态数组({B,5,1}可以看作0状态)经过一个a可以到达 ...