在命令行下使用
1 |
$ brew install FORMULANAME |
就可以安装 FORMULANAME 对应的工具,它会处理好依赖关系,非常方便。默认情况下,安装最新版本。但是现在在使用 Gradle 的时候,最新版本的 Gradle 是1.10,但是编译Android 的项目失败,只能降级成 1.9 版本的才行,解决方法如下
1.查看 brew 支持哪些版本的 gradle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
$ sudo brew versions gradle Warning: brew-versions is unsupported and may be removed soon. Please use the homebrew-versions tap instead: https://github.com/Homebrew/homebrew-versions 1.10 git checkout 2b10422 Library/Formula/gradle.rb 1.9 git checkout 5bab5e9 Library/Formula/gradle.rb 1.8 git checkout 9214e60 Library/Formula/gradle.rb 1.7 git checkout f826cc9 Library/Formula/gradle.rb 1.6 git checkout fff7c0b Library/Formula/gradle.rb 1.5 git checkout 57931e0 Library/Formula/gradle.rb 1.4 git checkout 0b7303a Library/Formula/gradle.rb 1.3 git checkout c259bda Library/Formula/gradle.rb 1.2 git checkout 9b7d294 Library/Formula/gradle.rb 1.1 git checkout 7941972 Library/Formula/gradle.rb 1.0 git checkout dff67fb Library/Formula/gradle.rb 1.0-rc-3 git checkout 5f9e348 Library/Formula/gradle.rb 1.0-rc-2 git checkout f72e33f Library/Formula/gradle.rb 1.0-rc-1 git checkout e2438cf Library/Formula/gradle.rb 1.0-milestone-9 git checkout c27c667 Library/Formula/gradle.rb 1.0-milestone-8a git checkout 69eb948 Library/Formula/gradle.rb 1.0-milestone-8 git checkout 34da975 Library/Formula/gradle.rb 1.0-milestone-7 git checkout 6a8c437 Library/Formula/gradle.rb 1.0-milestone-6 git checkout dae625d Library/Formula/gradle.rb 1.0-milestone-5 git checkout baff305 Library/Formula/gradle.rb 1.0-milestone-3 git checkout d9f2e06 Library/Formula/gradle.rb 1.0-milestone-4 git checkout 4b1230c Library/Formula/gradle.rb 1.0-milestone-2 git checkout 6801464 Library/Formula/gradle.rb 1.0-milestone-1 git checkout 0476235 Library/Formula/gradle.rb 0.9.2 git checkout 38b9338 Library/Formula/gradle.rb 0.9.1 git checkout f986d7d Library/Formula/gradle.rb 0.9 git checkout 45e09d7 Library/Formula/gradle.rb 0.8 git checkout e6f608f Library/Formula/gradle.rb |
可以看到,支持 1.9 版本的。
2. 进入 brew 所在的git仓库
1 |
$ cd `brew --prefix` |
3.复制粘贴刚才 brew versions gradle
命令的提示,我们需要1.9 版本的,因此执行
1 |
$ git checkout 5bab5e9 Library/Formula/gradle.rb |
此时,本地仓库中的gradle 就被替换成了 1.9 的链接地址信息。
4. 安装
1 2 |
$ sudo brew install gradle ==> Downloading http://services.gradle.org/distributions/gradle-1.9-bin.zip |
可以看到输出的信息已经是 1.9 的版本了。