Questions tagged [android-ktx]

Android KTX is an open source set of Kotlin Extensions which aims to make Kotlin code more simple and clean when developing for the Android Platform. DO NOT use this tag in questions about the Android Kotlin Extensions plugin.

Android KTX is a library developed by Google that simplifies the way Android Apps are written with Kotlin. It is still in preview and may change anytime.

Resources

40 questions
19
votes
3 answers

Compile errors after updating to WorkManager 1.0.0-alpha09

I'm trying to use WorkManager from architecture components. I've upgraded the compileSdkVersion and targetSdkVersion from 27 to 28. gradle sync is successfully done. But build-time error keeps popping up. android.support libraries are using version…
18
votes
3 answers

Kotlin extensions for Android: How to use bundleOf

Documentation says: fun bundleOf(vararg pairs: Pair): Bundle Returns a new Bundle with the given key/value pairs as elements. I tried: val bundle = bundleOf { Pair("KEY_PRICE", 50.0) Pair("KEY_IS_FROZEN", false) …
Malwinder Singh
  • 5,696
  • 11
  • 49
  • 88
12
votes
1 answer

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

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()…
Yurii Tsap
  • 3,028
  • 2
  • 18
  • 30
12
votes
2 answers

Android KTX or Anko

I'm a little confused about the advantages and disadvantages of using Android KTX vs Anko. Because both libraries are trying to achieve the same end goal, and the line between them it's getting a little bit blurry to the point, in some cases, the…
Arturo Mejia
  • 1,697
  • 1
  • 13
  • 23
7
votes
1 answer

Disabling Kotlin synthetic bindings when using Android data binding

I'm working through this Udacity course on Android/Kotlin/KTX. The "About Me" application introduces data binding, while the Android team seems to advise against using KTX binding. So I would like to do the former instead of the latter. However,…
Joe Lapp
  • 1,303
  • 2
  • 16
  • 28
7
votes
3 answers

Where is the KTX toast extension function?

I have learned from this article Even Sweeter Android development with Android KTX (https://www.kotlindevelopment.com/even-sweeter-android-ktx-kotlin/) that Android toast can be simplified using KTX from Toast.makeText(context,…
Shreck Ye
  • 1,122
  • 1
  • 8
  • 22
6
votes
2 answers

Androidx Activity OnBackPressedCallback Interface Issue

implementation("androidx.core:core-ktx:1.1.0-alpha04") implementation ("androidx.appcompat:appcompat:1.0.2") implementation ("androidx.activity:activity-ktx:1.0.0-alpha05") I was also looking at this Why are their 2 different ComponentActivity…
display name
  • 799
  • 9
  • 18
6
votes
3 answers

Androidx error inflating view

I'm trying to use Androidx. The app is pretty new, so there is not much code. I did use the "Refactor to Androidx" option in android studio. But sometime after that, it stopped working. I don't know what made it stop working. What am I supposed to…
alvarlagerlof
  • 1,246
  • 1
  • 14
  • 26
4
votes
2 answers

Unresolved reference: viewModelScope - Android KTX

I'm trying to use the new viewModelScope() function provided by the new android ktx library. In the gradle file, I've added: implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.0.0' implementation 'androidx.core:core-ktx:1.0.2' but when I…
Toni Joe
  • 5,505
  • 8
  • 41
  • 62
4
votes
1 answer

Gradle build fails after adding core ktx

When I add the core-ktx dependency to my app's build.gradle file, my gradle builds fail with the error message AAPT2 error: check logs for details It furthermore tells that there are two attributes missing in values.xml. This file is located under…
Zonico
  • 160
  • 11
4
votes
2 answers

Object is not part of the schema for this Realm in Kotlin

I have one open class like this open class NewsResponse( @field:SerializedName("news") val news: List? = null ):RealmObject() And NewsItem class like this open class NewsItem( @field:SerializedName("created") val created: String? =…
theanilpaudel
  • 2,840
  • 8
  • 28
  • 55
3
votes
1 answer

Can we create custom Synthetic Kotlin Extensions in Android?

I'm interested in the Kotlin Synthetic Extensions for Android, and thought if we can do the same for custom files, like raw XML files that we keep in the project. For example, let's consider the synthetic views in Kotlin. import…
Sri Harsha Chilakapati
  • 10,962
  • 6
  • 46
  • 87
3
votes
2 answers

Android animation with KTX

I have some animations in my Android app and I'd like to change my code in order to take advantage of Android KTX. Sadly, I don't really understand the documentation about it. Could someone tell me how I can improve this code with the help of…
3
votes
1 answer

Why are there 2 different ComponentActivity classes?

I'm trying to handle back button presses in my fragments by registering an OnBackPressedCallback via addOnBackPressedCallback to receive onBackPressed() callbacks without needing to override the method in your activity (described Nov 5, 2018 release…
wooldridgetm
  • 2,336
  • 1
  • 13
  • 20
1
2 3