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 ...
随机推荐
- 织梦中data文件夹是存放什么内容的
dede(织梦)的data文件夹下的文件及文件夹也不少,我们来一个一个的介绍下. 1. admin文件夹 admin文件夹 管理员用到的文件夹,一般是后台的配置文件. 第一个文件,idc.txt 配置 ...
- JAVA WEB之Spring4.x JdbcTemplate
jdbcTemplate 说白了,他就是Spring提供用于简化数据库访问的类 基本jdbc驱动访问数据库 /* 一个简易好用的数据库连接和访问类 */ package cslg.cn.control ...
- OpenCV鼠标滑轮事件
鼠标的滑轮事件实现图像的缩放很方便,具体在回调函数中如下写: 其中scale可以在外部定义为全局变量,通过响应CV_EVENT_MOUSEWHEEL滑轮事件获取Scale的具体值. 获取Scale值需 ...
- MySQL Command Line Client显示中文的部分为空
一连接数据库的时候就设置如下: 先设置 set names gbk,然后再插入就显示中文
- xml格式字符串转为Map
import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.Element;import org.dom ...
- 设置PATH和CLASSPATH
每天玩java的,如果连这门语言背景一点都熟悉的话,说出去真的是挺丢人的一件事情. 首先,java具有最强大的2个特点:功能强大,简单易用.出去android不说,这门语言衍生出太多的开源框架了,这也 ...
- js 生成 UUID
在项目中遇到要生成 UUID 的需求,第一反应就是有没有原生的生成方法,找了找,发现没有,只能自己建立算法 function. 下面是我用的算法 function uuid(len, radix) { ...
- jspf与jsp的区别
如果想把一个jspf的文件引入(incurred)到一个jsp页面中,只能使用"@include"指令引入 如果使用<jsp:include>引入,jspf文件中的内容 ...
- 如何为form表单的button设置submit事件
若button按钮没有type属性,浏览器默认按照type=submit逻辑处理,这样若将没有type的button放在form表单中,点击按钮就会执行form表单提交
- 面向对象_05【类的继承:extends、重写父类】
类的继承:现有类的基础上构建一个新的类,构建出来的类被称作子类,子类可继承父类的属性和方法. 什么时候定义继承?当类与类之间存在着所属关系的时候,就定义继承.xxx是yyy中的一种==>xxx ...