hulooq
353 天前
1. 启用 Instant Run
Instant Run 可增量编译和部署代码,减少编译时间和内存使用。
2. 调整 Gradle 设置
减少 maxHeapSize 和 minHeapSize Gradle 属性,在 Android Studio 的启动脚本中添加 -Xmx 和 -Xms 参数,将其设置为较低的值(例如 1024m )。
禁用 dexOptions.preDexLibraries ,因为它会增加内存使用。
3. 优化代码
避免创建大量对象和垃圾。
使用 final 和 static 修饰符来提高性能。
优化算法和数据结构。
4. 配置 Android Studio
在 "Preferences > Build, Execution, Deployment > Compiler" 中,将 "Compile Java Bytecode" 设置为 "Incremental"。
在 "Preferences > Editor > General > Appearance" 中,禁用 "Show Line Numbers" 和 "Show Method Separators"。