Kotlin 运行时 jar 与 kotlin stdlib jar
Kotlin runtime jar vs kotlin stdlib jar
kotlin-runtime.jar
(225.1K) 和 kotlin-stdlib.jar
(727.3K) 之间有什么区别(大小适用于 1.0.0-beta-1103
版本)?我应该随我的应用程序分发哪一个?现在我使用 kotlin-stdlib.jar
,因为那是 Android Studio 生成的,但我想知道我是否可以使用 kotlin-runtime.jar
,因为它更小。
运行时库仅包含执行编译代码所需的基本 Kotlin 语言类型。这是所需的最小 类 集。
标准库包含舒适开发所需的实用函数。这些是用于集合操作、文件、流等的函数。
理论上你可以只使用运行时但你通常不应该因为它没有标准库所以你会失去许多舒适开发所需的实用功能(例如map
,filter
, toList
等等)所以我认为你不应该这样做。
所以事实上你两者都需要。如果您需要使结果包更小,那么您可以使用 proguard 处理您的应用程序。
更新
从 Kotlin 1.2 开始,kotlin-runtime
和 kotlin-stdlib
合并为单个工件 kotlin-stdlib
。
We merge kotlin-runtime and kotlin-stdlib into the single artifact kotlin-stdlib. Also we’re going to rename kotlin-runtime.jar, shipped in the compiler distribution, to kotlin-stdlib.jar, to reduce the amount of confusion caused by having differently named standard library in different build systems.
That rename will happen in two stages: in 1.1 there will be both kotlin-runtime.jar and kotlin-stdlib.jar with the same content in the compiler distribution, and in 1.2 the former will be removed.
kotlin-runtime.jar
(225.1K) 和 kotlin-stdlib.jar
(727.3K) 之间有什么区别(大小适用于 1.0.0-beta-1103
版本)?我应该随我的应用程序分发哪一个?现在我使用 kotlin-stdlib.jar
,因为那是 Android Studio 生成的,但我想知道我是否可以使用 kotlin-runtime.jar
,因为它更小。
运行时库仅包含执行编译代码所需的基本 Kotlin 语言类型。这是所需的最小 类 集。
标准库包含舒适开发所需的实用函数。这些是用于集合操作、文件、流等的函数。
理论上你可以只使用运行时但你通常不应该因为它没有标准库所以你会失去许多舒适开发所需的实用功能(例如map
,filter
, toList
等等)所以我认为你不应该这样做。
所以事实上你两者都需要。如果您需要使结果包更小,那么您可以使用 proguard 处理您的应用程序。
更新
从 Kotlin 1.2 开始,kotlin-runtime
和 kotlin-stdlib
合并为单个工件 kotlin-stdlib
。
We merge kotlin-runtime and kotlin-stdlib into the single artifact kotlin-stdlib. Also we’re going to rename kotlin-runtime.jar, shipped in the compiler distribution, to kotlin-stdlib.jar, to reduce the amount of confusion caused by having differently named standard library in different build systems. That rename will happen in two stages: in 1.1 there will be both kotlin-runtime.jar and kotlin-stdlib.jar with the same content in the compiler distribution, and in 1.2 the former will be removed.