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 ...
随机推荐
- sqlite数据库的char,varchar,text,nchar,nvarchar,ntext的区别
1.CHAR.CHAR存储定长数据很方便,CHAR字段上的索引效率级高,比如定义char(10),那么不论你存储的数据是否达到了10个字节,都要占去10个字节的空间,不足的自动用空格填充. 2.VAR ...
- protobuf java基础
1:定义proto文件: 以一个地址薄为例,从建立一个.proto文件开始,为需要序列化的数据接口加入一个message属性,在message里面,为每一个字段指定名称和类型(算是IDL吧),如下 ...
- id,is的用法,小数据池的概念及编码知识进阶
一:id 查询内存地址 name = 'alex' print(id(name)) li = [1,2,3] print(id(li)) 二:is 判断的是内存地址 name1 = 'alex@' ...
- JavaScript总结学习一:js中构造函数与普通函数的区别
构造函数不仅只出现在JavaScript中,它同样存在于很多主流的程序语言里,比如c++.Java.PHP等等.与这些主流程序语言一样,构造函数在js中的作业一样,也是用来创建对象时初始化对象,并且总 ...
- Activity内切换fragment实现底部菜单切换遇到的坑
1.一般说来,app底部导航都会设计为5个菜单,可以使用textView,也可使用radioButton,这里我选择用radioButton,给radioButton直接设置selector就可以实现 ...
- [转]CentOS Apache 性能调试!
查看Apache的并发请求数及其TCP连接状态: netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' 返回结果示例 ...
- junit源码解析--捕获测试结果
OK,前面的博客我们整理了junit运行完了所有的测试用例,那么OK了,现在开始该收集测试结果了. 在这最后一步中,junit主要是玩一个类,TestResult.这里类中封装了几个参数,在初始化这个 ...
- WebSphere--安装与配置
对于任何软件,都需要一些计划和具体步骤以确保成功安装.对于安装与配制 WebSphere应用服务器及其组件也是如此.下面介绍在Windows NT 上安装与配置WebSphere应用服务器 1 ...
- Using $this when not in object context in
错误信息:$this引用没有上下文 原因:在PHP5中,static声明的静态方法里不可以使用$this 需要使用self来引用当前类中的方法或是变量. 引用的方法里不可以带$this(示例代码中为g ...
- 机器学习--kNN算法识别手写字母
本文主要是用kNN算法对字母图片进行特征提取,分类识别.内容如下: kNN算法及相关Python模块介绍 对字母图片进行特征提取 kNN算法实现 kNN算法分析 一.kNN算法介绍 K近邻(kNN,k ...