androidx.core:core-ktx:1.0.0 widget package missing
Asked Answered
D

1

12

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?

Delirium answered 17/10, 2018 at 11:10 Comment(2)
I've never used KTX but toast() seems coming from anko which I had to add anko in my project. However, where in beta01 I was able to use MaterialComponents now you can't use it or what, what have you tried? Would you describe the issue more?Dihedron
MaterialComponent-styles, I mean that I'm facing "cannot resolve style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox". while providing it on com.google.android.material.textfield.TextInputLayout view. But that was Android Studio issue, now it is able to see it, argh! toast() is an extension method from here 'androidx.core:core-ktx:1.0.0'.Delirium
S
4

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();.

Subak answered 3/12, 2018 at 15:27 Comment(2)
Hey, thanks a lot for your answer, that was helpful! I've fixed that issue by just adding that ext-fun to mine project. I haven't seen that topic, but I made a conclusion from that thread - toast() was removed because it could be disabled by user from Device settings. In such case toast won't be show until user enables that perm. Anyway that is definitely the right answer. Thanks!Delirium
@YuriiTsap, thank you very much for your reply! I didn't know this behaviour of a toast. I am glad that you are so clever specialist.Subak

© 2022 - 2024 — McMap. All rights reserved.