Android N Java 8 features (Jack compiler) and Kotlin interop

后端 未结 8 1729
抹茶落季
抹茶落季 2020-12-22 23:19

Update 3. KOTLIN IS NOW OFFICIALLY SUPPORTED FOR ANDROID DEVELOPMENT. BY GOOGLE. YAAAAAAAAS!

Update 2: It looks like JetBrains is r

相关标签:
8条回答
  • 2020-12-23 00:04

    UPDATE (03/16/2017)

    Luckily, Jack is dead and so it won't affect Kotlin developers.


    If Jack is the future then you will get stuck in the past with Kotlin. Currently Jack doesn't support plugins that can compile non-Java source into Dalvik bytecode. And even if it did JetBrains would need to add a new backend to the Kotlin compiler which is not a trivial task. So you will have to use Kotlin with Jill and it's going to be something very similar to the toolchain you use now.

    As you can see in the image below even if it's impossible to explicitly turn off Jack you'll still be able to convert the project to a library project to use Jill. And the application project will just reference this library project.

    The only way I see how Kotlin can work with Jack, which probably will not be implemented, is adding a Java backend to the Kotlin compiler, i.e. a backend that generates Java code like Xtend. In this case code generated by the Kotlin compiler can be processed by Jack as any other Java code.

    But at the moment we don't know exactly what Jack will support when it's released. Maybe something will change dramatically and adding Kotlin support to Jack will become possible.

    0 讨论(0)
  • 2020-12-23 00:08

    I've already found this blog post from the official Kotlin's blog: : Kotlin’s Android Roadmap

    There you would find a part which tells that:

    The next thing we plan to do to improve Android build performance is providing an integration with Android’s new Jack and Jill toolchain. Right now there are some issues that prevent Jack from handling Kotlin-generated bytecode correctly (196084 and 203531), but we plan to work together with the Google team to either resolve the issues or provide workarounds on our side. Once this is done, we’ll be able to translate only changed class files using Jill during incremental compilation, as opposed to translating all class files every time (which is the only possible behavior in the old Android tooling).

    So as @LukasBergstrom said, there won't be any problem with "stucking in the past" ;-)

    You can also check Reddit discussion linked with this topic: What is the status of Kotlin with Jack and Jill?

    Happy coding.

    0 讨论(0)
提交回复
热议问题