I have not used Android for a long time but now I find a new term, Kotlin, so my doubt is, JDK is required for Kotlin?
If Kotlin will replace to Java, so the JDK it is not necessary because according to me JDK is for develop on Java, is correct?
If it is correct then I have other doubt (this already it's old) why JDK is used for Android if this already include an Android SDK?
P. D. I am going crazy, I need a single explanation.
Kotlin 1.1. 2 now requires Java Development Kit (JDK) 8. “Most other Java development tools such as Gradle and the Android toolchain also require JDK 8, so you almost certainly already have it installed,” said Dmitry Jemerov, a principal engineer at JetBrains.
Since Android apps are written in Java, you will need the Oracle Java compiler and libraries on your system. These are collectively called the Java Development Kit or "JDK" for short.
Is Kotlin compatible with the Java programming language? Yes. Kotlin is 100% interoperable with the Java programming language and major emphasis has been placed on making sure that your existing codebase can interact properly with Kotlin.
The Android Kotlin compiler produces Java 8 bytecode by default (which runs in any later JVM), but lets the programmer choose to target Java 9 up to 18, for optimization, or allows for more features; has bidirectional record class interoperability support for JVM, introduced in Java 16, considered stable as of Kotlin ...
As already mentioned, Kotlin JVM requires the JVM to work. Kotlin compiles to JVM bytecode, which means it has the same requirements as Java (runtime and development kit). This is also why Kotlin has Java interop. Additionally, this is the one you're most likely to find yourself using with Android.
However, there is Kotlin Native. The SDK itself is slightly different from Kotlin JVM, and it's still a WIP, but it compiles without the need for JVM. Specifically, it compiles to a native target using LLVM. This version of Kotlin supports C interop.
Kotlin Native also opens the door for Kotlin Multiplatform, which compiles to whatever you want (mobile targets, desktop targets, and it packs it all into one, and includes interop with the native programming language). NOTE: I'm not sure what Kotlin Native with Multiplatform compiles to. Some demo projects use Kotlin JVM in the Android module, which suggests it doesn't use NDK-style native code. Multiplatforms, like Native, is experimental. I also haven't touched Multiplatform much, but it appears to be using a combination of declared functions and platform-declared functions. I'm not sure how interop works here (in terms of languages - not module interop).
Multiplatform doesn't require Native though, but it enables significantly more platforms. If you're using a cross-platform Java library (for an instance LibGDX), or otherwise build on modules with a core and platforms, you can use Multiplatform here too. However, note that this likely requires the JDK, although it does depend on your project.
In addition to these, there's also Kotlin.JS, which as the name suggests, compiles to JavaScript. Unlike Kotlin JVM, it naturally doesn't require the JVM. However, it instead requires the JavaScript-related APIs. And as you'd expect, Kotlin.JS supports JavaScript interop.
TL;DR:
The JDK isn't always required. Kotlin Native and Kotlin JS do not require the JDK, because the targets they compile to isn't on the JVM.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With