How to use all CPU cores/threads when running Android Studio gradle build?

前端 未结 3 704
青春惊慌失措
青春惊慌失措 2021-01-30 23:13

I\'m looking for a parameter or configuration in Android Studio / Gradle, that can set the build so it will use all of my CPU cores during build time. i.e. If I have a quad-co

3条回答
  •  花落未央
    2021-01-30 23:30

    TL; DR

    According to Gradle Build Environment Documentation:

    org.gradle.configureondemand=true
    org.gradle.daemon=true
    org.gradle.parallel=true
    org.gradle.workers.max=4             
    

    Details

    By default org.gradle.workers.max is set to the number of CPU processors (in my case 8).

    Since my Android Studio was freezing my Ubuntu workstation (sometimes forcing me to hard reset the computer), I have set it to 4, ensuring my workstation will not starve on CPU and memory.

提交回复
热议问题