Home » Android » android – androidx.core:core-ktx:1.0.0 widget package missing

android – androidx.core:core-ktx:1.0.0 widget package missing

Posted by: admin May 14, 2020 Leave a comment

Questions:

Recently Android team(mainly those guys actually) had introduced androidx.core:core-ktx:1.0.0.
I’ve added it to mine project :

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

Everything looks cool, despite few moments – I can’t find the toast() method. After few minutes of research I’ve found that androidx.core.widget package isn’t anymore present within the ktx lib. There is nothing about it mentioned inside Changelog file. That’s kind of strange, cause it was there within androidx.core:core-ktx:1.0.0-alpha1 version.

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?

How to&Answers:

As this library was archived and partially moved to support, you can see in https://github.com/android/android-ktx/issues/143 that toast() is removed. So you can downgrade the library to androidx.core:core-ktx:1.0.0-alpha1 (beta01 or even 0.3).

I don’t know, why this happened.

beta01 warns that toast() should be replaced with Toast.makeText(this, message, Toast.LENGTH_SHORT).show();.