(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
发表评论 取消回复