Mac下Gradle环境的配置

前言:

每一种语言发展到一定阶段都会有自动化工具的出现,比如javascript的npm,java的maven等等,android的gradle听说已久,而在最近的一个项目中看到了setting.gradle需要使用gradle工具进行下载配置,所以又在网上找了篇教程,自己慢慢琢磨起来。

1、下载

官网下载:http://www.gradle.org/get-started

参考文档:

For running Gradle, add GRADLE_HOME/bin to your PATH environment variable. Usually, this is sufficient to run Gradle.

GRADLE_HOME="/usr/local/share/gradle-1.12"
export PATH=$PATH:$GRADLE_HOME/bin

配置成功

 ~  gradle -version

------------------------------------------------------------
Gradle 1.12
------------------------------------------------------------

Build time:   2014-04-29 09:24:31 UTC
Build number: none
Revision:     a831fa866d46cbee94e61a09af15f9dd95987421

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
Ivy:          2.2.0
JVM:          1.7.0_51 (Oracle Corporation 24.51-b03)
OS:           Mac OS X 10.9.2 x86_64
2、Gradle简介

Gradle 是以 Groovy 语言为基础,面向Java应用为主。基于DSL(领域特定语言)语法的自动化构建工具。

在项目中,如果又setting.gradle,直接在项目文件加下输入:gradle build即可构建项目。

项目报错如下:

* Where:
Build file '/Users/lishuming/opensource/andriod/SomeProjects/rubychina4android/app/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> Gradle version 1.10 is required. Current version is 1.12. If using the gradle wrapper, try editing the distributionUrl in /Users/lishuming/opensource/andriod/SomeProjects/rubychina4android/gradle/wrapper/gradle-wrapper.properties to gradle-1.10-all.zip

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

尝试修改了build.gradle还是不行:

➜  rubychina4android git:(master) ✗ gradle build   

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'rubychina4android'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not find com.android.tools.build:gradle:1.12.
     Required by:
         :rubychina4android:unspecified

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

所以很无奈,又重新装了一遍1.10的版本了。

安装完成又出现错误

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/lishuming/opensource/andriod/SomeProjects/rubychina4android/app/build.gradle' line: 1

* What went wrong:
A problem occurred evaluating project ':app'.
> SDK location not found. Define location with sdk.dir in the local.properties file or with an ANDROID_HOME environment variable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.283 secs
待解决。。。

3、进一步学习

maven/ant/gradle构建项目的工具,因为都没有系统的学习过,想再以后的工作中细心研究研究,因为项目管理还是需要的。


你可能感兴趣的:(java,入门,安装,gradle,项目)