I have a question about the role of Gradle when us...
# kotlin-toolchain
v
I have a question about the role of Gradle when using Kotlin Toolchain for
android/app
product. Why does an
android/app
product still use Gradle for compilation/building? If Gradle is still required underneath, what are the main advantages of using Kotlin Toolchain over using Gradle directly? Also, is it technically possible (or planned) to build an
android/app
product without Gradle at all, with Kotlin Toolchain handling the complete build process? I'm asking because one of the things that interests me about Kotlin Toolchain is the possibility of a lightweight, fast build system without the overhead of a Gradle daemon. I'd love to understand what the intended architecture and long-term direction are here.
j
This is a fair question. TL;DR: we want to remove the delegation to Gradle, and eventually we will, but it will take some time. First of all, the Kotlin Toolchain already does a lot by itself in Android builds: • Android SDK provisioning • dependency resolution • Kotlin compilation • AAR packaging • Unit test execution • Emulator management and app execution What it delegates to Gradle for: • generating the mockable
android.jar
used in unit tests • resource processing to produce the
R
class before we can compile Kotlin code on our end • APK / AAB packing (using the classes compiled on our end, and dependencies we resolved) ◦ This includes artifacts transformation, D8 dexing, R8 minification, manifest merging, and signing For the mockable JAR, we already asked Google if they could extract the generator in a way we can reuse more easily, so we don't have to delegate that part to Gradle. For
R
, APK, and AAB, it's a bit more tricky, but the end game is indeed to replace this with delegation to Android tooling instead of Gradle. That may require some help from Google.
👍 2
👍🏽 1
Now, even in its current state, I'd say the benefit is the lean and simple configuration and the IDE assistance. If you do KMP and not just Android, you'll also benefit on all other platforms.
❤️ 3