Android Jetpack是否需要使用Kotlin语言? [英] Does Android Jetpack require the use of the Kotlin language?

查看:443
本文介绍了Android Jetpack是否需要使用Kotlin语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在Google中找到明确的答案,而且我为Jetpack查看的所有文档和示例似乎都引用并使用了Kotlin.

I can't seem to find a clear answer to this in Google, and all the documentation and samples I've seen for Jetpack seem to refer to and use Kotlin.

但是您是否必须使用Kotlin才能使用Jetpack?还是可以将Jetpack与传统的Java程序一起使用?

But do you HAVE to use Kotlin in order to use Jetpack? Or can Jetpack be used with traditional Java programs?

我一直在看Kotlin,但它为您的应用程序大小增加了将近MB.而且,由于目前我的整个应用程序只有200KB,我认为Kotlin不值得将应用程序的大小增加500%!

I was looking at Kotlin but it adds almost a MB to your app size. And seeing as my entire app is only about 200KB currently, I don't think Kotlin is worth increasing the size of my app by 500%!

推荐答案

Jetpack是一个库的集合,以及有关Google建议如何构建Android应用程序的指南.这些库都具有Java API,因此您无需使用Kotlin就可以使用它们.两种语言仍完全支持Android开发.

Jetpack is a collection of libraries plus guidance on how Google recommends building Android applications. These libraries all have Java APIs, so you don't need to move to Kotlin to use any of them. Both languages are still completely supported for Android development.

关于APK大小的考虑,确实Kotlin一定会增加它.很难说它会有多大,但是Proguard应该去除很多您最终没有使用的标准库,因此它可能比整个MB小得多. 此处比较了一个基本为空的Hello world应用的Java和Kotlin APK大小的文章例如,发现增加仅为11 KB.因此,除非您在一个非常重要的市场中,否则可能无法使用Kotlin.

As for the APK size consideration, it's true that Kotlin will definitely increase it. It's hard to tell how much larger it'll be, but Proguard should strip out a lot of the standard library that you end up not using, so it could be much less than an entire MB. Here's an article that compared Java and Kotlin APK sizes of an essentially empty Hello world app that found the increase to be just 11 KBs, for example. So unless you're in a market where this is extremely important, you could probably get away with using Kotlin.

但是,更重要的是,切换到Kotlin不仅是引入一个库-它是一种新的学习语言,这意味着您必须付出一些努力,并且它可能会在编写应用程序方面发生很大变化.您应该更多地研究该语言,然后看看您是否喜欢它所提供的功能.

More importantly though, switching to Kotlin is more than just pulling in a library - it's a new language to learn, which means you have to put some effort into it, and it can change a lot about how you write your applications. You should look into the language more and see if you like what it offers.

这篇关于Android Jetpack是否需要使用Kotlin语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆