In typical cases such as running tests from IntelliJ IDEA or starting the app from Xcode, the Kotlin tooling avoids executing unnecessary tasks.
These tasks build the same code more than once, increasing the compilation times. Don't run Gradle tasks that build the whole project, such as build or assemble, unless you really need to. If you use parallel builds, you might need to make the heap even larger or choose the right number of threads with .īuild only the binaries you need. Here are some recommendations for configuring Gradle for better compilation performance: You should build your project at least twice to get an accurate reading of the actual compilation times. The first compilation with Gradle usually takes more time than subsequent ones due to the need to download the dependencies, build caches, and perform additional steps.
For example, redefine its location using the KONAN_DATA_DIR environment variable. To avoid this step, configure your environment to preserve ~/.konan between builds. When building in containers (such as Docker) or with continuous integration systems, the compiler may have to create the ~/.konan directory from scratch for each build. The compiler uses this directory for subsequent compilations, making them take less time to complete. When compiling projects, Kotlin/Native downloads the required components and caches some results of its work to the $USER_HOME/.konan directory. Preserve downloaded and cached components between builds. They take a long time to compile and load during execution. This way you will always have the latest performance improvements.Īvoid creating huge classes.
Compiledebug is ambiguous gradle android studio how to#
Read on for our tips on how to speed up the Kotlin/Native compilation process. With the latest Kotlin/Native compiler and a properly configured build environment, you can significantly improve the compilation times of your projects with Kotlin/Native targets. The Kotlin/Native compiler is constantly receiving updates that improve its performance. Tips for improving Kotlin/Native compilation times