增加 gradle 堆大小

Increasing the gradle heap size

每当我尝试构建应用程序时,gradle 会花费太多时间,并且会出现一条消息,显示您应该将 Gradle 大小增加到 3072 MB,目前是910 兆字节。所以我的问题是如何增加 gradle 的堆内存 ??

只需添加

 android {
 ....
 dexOptions {
    // Prevent OutOfMemory with MultiDex during the build phase
    javaMaxHeapSize "4g"
  }
}

在您的 build.gradle 文件中