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 许可协议。转载请注明出处!
相关文章
该死的应用闪退,终于解决error-while-inflating-CardView
前言 (先来一个微笑脸)这个问题已经困扰我好久了,之前各种搜索无果,得到的解决方案无非就是 AppCompact 和 CardView 包的版本不一样云云,然而我根本没有这个问题。(怕是不把我Gradle看在眼里?) 问题 就是这么个界面,用到了RecycleView和Cardview,但是在SDK 23以下都不行,官方已经写明这个组件是支持到SDK9还是10的,反正基本是个android手机就可
2022-08-22 · Android开发 · 约 1 分钟
Android-ORM-框架:GreenDao入门
GreenDao 简介 GreenDAO 是一款开源的面向 Android 的轻便、快捷的 ORM 框架,将 Java 对象映射到 SQLite 数据库中,我们操作数据库的时候,不在需要编写复杂的 SQL语句, 在性能方面,GreenDAO 针对 Android 进行了高度优化, 最小的内存开销 、依赖体积小 同时还是支持数据库加密。 GreenDAO 官网地址:http://greenrobot
2022-05-27 · Android开发 · 约 1 分钟
记一次AndroidStudio在Linux环境上的奇葩错误,Argument-for-@NotNull-parameter-'messag
错误信息 Argument for @NotNull parameter 'message' of com/android/tools/idea/gradle/project/sync/GradleSyncState.syncFailed must not be null java.lang.IllegalArgumentException: Argument for @NotNull param
2022-05-27 · Android开发 · 约 1 分钟
Android开发:解决在Linux上提示-dev-kvm-device-permission-denied问题
操作步骤 我用的是Ubuntu系统,首先需要安装qemu-kvm: sudo apt install qemu-kvm 将当前用户添加到kvm用户组: sudo adduser $USER kvm 检查/dev/kvm所有者: ls -al /dev/kvm 一般结果就是所有者是root以及kvm这个组 添加完了之后检查一下kvm组里有没有你的用户名: grep kvm /etc/group 一般
2021-12-18 · Android开发 · 约 1 分钟
讨论
共 0 条加载评论中…