#Grandle 小结
[toc]
Could not find property 'Compile' on root project
- 问题原因及解决方法
Gradle 2.0前 gradle.build tasks.withType(Compile) { options.encoding = "UTF-8" }复制代码
升级到2.0后 tasks.withType(JavaCompile) { options.encoding = "UTF-8" }复制代码
Could not compile build file 'Path\build.gradle'.
- 问题原因及解决方法
一般情况是build.gradle存在语法错误。本次遇到的为 jar { manifest { attributes 'Implementation-Title': 'DPModel', 'Implementation-Version': 1.0.0 } } 更改为 jar { manifest { attributes 'Implementation-Title': 'DPModel', 'Implementation-Version': '1.0.0' } }复制代码
未增加中央仓储导致配置的dependencies无法下载
- 解决方法
在构建文件中加入仓储地址Gradle支持从maven中央仓库和JCenter上获取构件,那这两者有什么区别呢?repositories { mavenCentral() }复制代码
maven中央仓库(repo1.maven.org/maven2/)是由S… Maven、SBT和其他构建系统的默认仓库,并能很容易被Apache Ant/Ivy、Gradle和其他工具所使用。开源组织例如Apache软件基金会、Eclipse基金会、JBoss和很多个人开源项目都将构件发布到中央仓库。 maven中央仓库已经将内容浏览功能禁掉了,可在search.maven.org/ 查询构件。
jcenter仓库(jcenter.bintray.com )是由JFrog公司提供的Bintray中的Java仓库。它是当前世界上最大的Java和Android开源软件构件仓库。 所有内容都通过内容分发网络(CDN)使用加密https连接获取。JCenter是Goovy Grape内的默认仓库,Gradle内建支持(jcenter()仓库),非常易于在(可能除了Maven之外的)其他构建工具内进行配置。
JCenter相比mavenCenter构件更多,性能也更好。但还是有些构件仅存在mavenCenter中。