最近安卓团队(主要是guys人)推出了androidx.core:core-ktx:1.0.0.

implementation 'androidx.core:core-ktx:1.0.0'

一切看起来都很酷,尽管有一些时刻——我找不到toast()方法.经过几分钟的研究,我发现在ktx库中不再存在androidx.core.widget包.这件事在Changelog file页里没有提及.这有点奇怪,因为它就在androidx.core:core-ktx:1.0.0-alpha1版本内.

BTW the same strange behaviour applies to com.google.android.material:material:1.0.0 where in beta01 I was able to use MaterialComponents-styles and in the release version Android Studio isn't able to resolve them. As usual after few hours of playing with Android Studio(using diff lib versions and invalidating cache) things went back to normal. Problem with styles isn't valid anymore.

Soooo, the question is:

What was done? Do we have any up to date doc describing all relevant changes?

推荐答案

由于此库已存档并部分移动到了support,您可以在https://github.com/android/android-ktx/issues/143中看到toast()已被删除.因此,您可以将库降级到androidx.core:core-ktx:1.0.0-alpha1(beta01甚至0.3).

I don't know, why this happened.

beta01警告toast()应该被Toast.makeText(this, message, Toast.LENGTH_SHORT).show();取代.

Kotlin相关问答推荐

在调用父构造函数之前重写类属性

如何创建一个空的kotlin工作?

如何更改默认推断没有接收者的函数类型?

kotlin短路列表判断吗?

Kotlin 获取继承类的默认 hashCode 实现

将一个列表元素分组为多个组(indexBy)

在 Compose 中使用 Text() 时如何获取文本的大小?

为什么 KFunction2 在 Kotlin 中不是可表示类型?

为 Gradle 子项目配置 Kotlin 扩展

这是什么 Kotlin 类型:(String..String?)

有没有办法重用 Job 实例?

Kotlin:内部类如何访问在外部类中声明为参数的变量?

Kotlin-通过与属性列表进行比较来筛选对象列表

封闭 lambda 的隐式参数被shadowed

TypeConverter()在Android的TypeConverter错误中具有私有访问权限

Kotlin中OnclickListener方法之间的差异

如何将vararg作为数组传递给Kotlin中的函数?

如何在 Gradle Kotlin DSL 中使用来自 gradle.properties 的插件版本?

Kotlin - 如果不为空,则使用修改后的 Obj props 覆盖 Obj props

从 Kotlin 访问 Integer.class