为Android Studio 项目手动下载gradle

网上下载的例子,导入Android Studio的时候,第一件事就是下载项目对应版本的gradle。

gradle是一个主要面向Java应用的build工具,类似于大家熟知的eclipse下的Ant,但比Ant高级。


Andriod Studio下载gradle的过程很慢,在运行./studio.sh的终端中可以看见进度:

把终端中的网址复制下来,在浏览器中打开,可见有38MB多。Windows下可用迅雷下载,Linux下推荐Firefox + DownThemAll插件。

各个版本gradle地址:https://services.gradle.org/distributions

Android Studio下载的各个版本gradle放在~/.gradle/wrapper/dists/目录下(Windows下目录为C:\Users\用户名\.gradle\wrapper\dists)。如下显示了Andriod Studio已经下载了gradle部分文件的大小,可见已经下载了20MB左右:

wy@wy-Inspiron-7420:~/.gradle/wrapper/dists/gradle-1.10-bin/6oa4rff9viiqskhgd6uns5v1f8$ ll
total 21432
drwxrwxr-x 2 wy wy     4096 Sep 28 00:27 ./
drwxrwxr-x 3 wy wy     4096 Sep 28 00:20 ../
-rw-rw-r-- 1 wy wy        0 Sep 28 00:20 gradle-1.10-bin.zip.lck
-rw-rw-r-- 1 wy wy 21931207 Sep 28 00:33 gradle-1.10-bin.zip.part

在Android Studio中取消下载(不过貌似有个bug,取消不了,那就直接在运行studio.sh的终端中按Ctrl + C 退出Android Studio)。

将gradle-1.10-bin.zip.part移除,把自己下载的gradle-1.10-bin.zip复制到这个目录。然后再次启动Andriod Studio,会自动读取gradle并解压,然后用解压得到的gradle工具build你import进来的sample project。

再次查看gradle的下载目录,如下:

复制代码
wy@wy-Inspiron-7420:~/.gradle/wrapper/dists/gradle-1.10-bin/6oa4rff9viiqskhgd6uns5v1f8$ ll
total 39472
drwxrwxr-x 3 wy wy     4096 Sep 28 00:38 ./
drwxrwxr-x 3 wy wy     4096 Sep 28 00:20 ../
drwxrwxr-x 6 wy wy     4096 Sep 28 00:38 gradle-1.10/
-rw-r----- 1 wy wy 40404574 Sep 28 00:37 gradle-1.10-bin.zip
-rw-rw-r-- 1 wy wy        0 Sep 28 00:20 gradle-1.10-bin.zip.lck
-rw-rw-r-- 1 wy wy        0 Sep 28 00:38 gradle-1.10-bin.zip.ok
复制代码

lck和ok文件大小为0,没有实际内容,起一个标志的作用。ok表示此版本的gradle已经收拾妥当(在下载完毕之前是没有这个ok文件的)。lck文件不知什么作用。(猜测是lock的意思,标记这个版本的gradle是否有project在使用。如果没有被使用,当总的gradle文件达到缓存上限后,此版本的gradle会被删除)

About This Book, Create custom Gradle tasks and plugins for your Android projects, Configure different build variants, each with their own dependencies and properties, Manage multi-module projects, and integrate modules interdependently, Who This Book Is For, If you are an experienced Android developer wanting to enhance your skills with the Gradle Android build system, then this book is for you. As a prerequisite, you will need some knowledge of the concepts of Android application development., What You Will Learn, Build new Android apps and libraries using Android Studio and Gradle, Migrate projects from Eclipse to Android Studio and Gradle, Manage the local and remote dependencies of your projects, Create multiple build variants, Include multiple modules in a single project, Integrate tests into the build process, Create custom tasks and plugins for Android projects, In Detail, Gradle is an open source build automation system that introduces a Groovy-based domain-specific language (DSL) to configure projects. Using Gradle makes it easy for Android developers to manage dependencies and set up the entire build process., This book begins by taking you through the basics of Gradle and how it works with Android Studio. Furthermore, you will learn how to add local and remote dependencies to your project. You will work with build variants, such as debug and release, paid and free, and even combinations of these things. The book will also help you set up unit and integration testing with different libraries and will show how Gradle and Android Studio can make running tests easier. Finally, you will be shown a number of tips and tricks on the advanced customization of your application's build process. By the end of this book, you will be able to customize the entire build process, and create your own tasks and plugins for your Gradle builds.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值