Android Development: A Record of Wrestling with Gradle
Preface A bit annoying. I recently upgraded my computer, adding RAM and an SSD, but the new RAM wasn't very compatible and caused frequent crashes. After I went to the seller and swapped the RAM stick, it was fine, but that also led me to rashly reinstall the system = =... I had some files on the system drive that I forgot to save, so they were lost. I only finished setting up the new system this afternoon, so I haven't been able to write posts these past two days. (Gotta say Chrome is really useful; the sync feature saved me a lot of trouble.) First, a rant about Gradle Downsides: it eats a lot of resources, is slow, and the network is even worse when using it in China. This
目录4 个章节
Preface
A bit annoying. I recently upgraded my computer, adding RAM and an SSD, but the new RAM wasn't very compatible and caused frequent crashes. After I went to the seller and swapped the RAM stick, it was fine, but that also led me to rashly reinstall the system = =... I had some files on the system drive that I forgot to save, so they were lost. I only finished setting up the new system this afternoon, so I haven't been able to write posts these past two days. (Gotta say Chrome is really useful; the sync feature saved me a lot of trouble.)
First, a rant about Gradle
Downsides: It eats a lot of resources, is slow, and the network is even worse when using it in China.
This afternoon while setting up the environment, this thing wasted a ton of my time.
At first the Gradle files wouldn't download; after I downloaded them manually, the dependency packages wouldn't download. I was so done. I spent ages hunting for mirrors and downloading things by hand and still couldn't get it working. (No experience.)
You ask why I didn't use a proxy?? What? I did set a SOCKS proxy, but it completely ignored me—the places that wouldn't download still wouldn't download, and the Maven repos still didn't work.
I won't ramble on any further; here's the solution:
The correct way to set a proxy is like this—edit gradle.properties:
Location of this file: Linux/Mac:
~/.gradle/gradle.propertiesWindows:C:\Users\你的用户名\.gradle\gradle.properties
I'll eat my words if setting a SOCKS proxy actually works. Also, you MUST set https!
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
After setting the proxy, run ./gradlew build in the Project Root and there shouldn't be much of a problem. If there are errors, just follow the messages to fix them. I prefer using the command line; it's more straightforward than an IDE.
Optimizing Gradle Speed
Gradle's poor performance is well known. How to fix it? Throw hardware at it, you want to get stronger without paying?
Enough talk—just edit this gradle.properties:
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
And also configure it in the IDE:

emmmm
Yeah, that's about it for this Gradle configuration. Now I get a bit anxious whenever I see that word—somehow it brings back the fear of being dominated by Gradle.
I'm out~
_EOF_
Android Development: A Record of Wrestling with Gradle
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
Android开发:在Linux系统上使用ADB连接Android手机
前言 由于 Linux 系统的安全性设置等原因,非 root 用户使用外部设备或者某些硬件接口会受到限制。Google 官方提供的 SDK 并不能直接工作,如找不到设备或者显示一堆问号以及 Permission Denied。 方法 记得以前有看过 Google 官方提供的解决方案,即将指定的 USB 设备读写权限赋予普通用户。 首先使用 lsusb 命令查看连接到计算机的 usb 设备,找到 A
2021-12-18 · Android开发 · 约 1 分钟
该死的应用闪退,终于解决error-while-inflating-CardView
前言 (先来一个微笑脸)这个问题已经困扰我好久了,之前各种搜索无果,得到的解决方案无非就是 AppCompact 和 CardView 包的版本不一样云云,然而我根本没有这个问题。(怕是不把我Gradle看在眼里?) 问题 就是这么个界面,用到了RecycleView和Cardview,但是在SDK 23以下都不行,官方已经写明这个组件是支持到SDK9还是10的,反正基本是个android手机就可
2022-08-22 · Android开发 · 约 1 分钟
Android-Studio-插件记录
GsonFormat https://blog.csdn.net/leejizhou/article/details/50557786 ButterKnifeZelezny http://blog.csdn.net/leejizhou/article/details/50541356 SQLScout SQLite调试神器。 http://www.idescout.com/ https://plu
2021-12-18 · Android开发 · 约 1 分钟
Android开发:使用CardView实现卡片式设计
开头引用一段官网的介绍 A FrameLayout with a rounded corner background and shadow. CardView uses elevation property on Lollipop for shadows and falls back to a custom emulated shadow implementation on older platf
2021-12-18 · Android开发 · 约 1 分钟
讨论
共 0 条加载评论中…