Android Gradle 手动下载

本文介绍了如何解决Android Studio更新Gradle导致长时间构建的问题。通过手动下载并配置Gradle版本,可以有效避免长时间等待和资源浪费。具体步骤包括修改build.gradle文件、更新Gradle版本以及手动下载Gradle。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Android Gradle 手动下载

博主博客

Android Studio 升级到 2.3 之后, 进去项目中, Android Studio 会提示更新 Gradle。只要一更新Gradle就会build很久, 不知道什么时候才能停下来, 最后被迫把进程kill掉。最后到官方下载了最新的Gradle手动导进去,在这说一下步骤吧。

1. 修改 build.gradle 文件

buildscript {
  ...
  dependencies {
    classpath 'com.android.tools.build:gradle:2.3.0'
  }
}

如果没有自动更新可以点击 Tools > Android > Sync Project with Gradle Files进行更新。

2.更新 Gradle

修改 gradle/wrapper/gradle-wrapper.properties 文件,例如要设置成 Gradle 3.3 版本的

...
distributionUrl = https\://services.gradle.org/distributions/gradle-3.3-all.zip
...

当设置完之后, Android Studio 一直在 build, 那么大多数都是在下载 Gradle 的原因, 如果觉得慢可以把 Gradle 降低版本, 降到本地有的版本就不会去下载, 如果想更新可以进行以下操作。

3.手动下载 Gradle

  • 可以到这里下载。选择需要下载的版本, 然后下载即可。
  • 下载完之后, 先把Android Studio 关了, 如果还在 build 直接用任务管理器关了吧。
  • 找到C:\Users\用户名\.gradle\wrapper\dists这个位置。
  • 如果已经在下载 Gradle, 那么就会自动生成相对应的 Gradle 文件夹。
  • 例如我的是 gradle-3.3-all , 然后把C:\Users\用户名\.gradle\wrapper\dists\gradle-3.3-all\数字加英文的文件夹里面的文件删掉, 把下载好的 gradle-3.3-all.zip 放在这个位置。
  • 最后重新打开 Android Studio, 然后它会自动解压, 自动配置, 不需要重新下载了。
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
发出的红包

打赏作者

nukix

如果觉得对你有帮助,欢迎打赏!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值