Questions related to Kotlin Android Extensions
Questions tagged [kotlin-android-extensions]
721 questions
16
votes
1 answer
Unit test on Kotlin Extension Function on Android SDK Classes
Kotlin extension function is great. But how could I perform unit test on them? Especially those that is of Android SDK provided class (e.g. Context, Dialog).
I provide two examples below, and if anyone could share how I could unit test them, or if I…

Elye
- 53,639
- 54
- 212
- 474
15
votes
3 answers
kotlin-android-extensions in ViewHolder
class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bindata(text: SingleText){
itemView.title.text = text.title
itemView.desc.text = text.desc
}
}
like this code, Kotlin has any cache…

wanbo
- 868
- 9
- 24
15
votes
2 answers
How to use fragments with kotlin
I can not find how to use fragments using kotlin.
I get an error in the onCreateView method, please help me.
ListaFragment.kt:
class ListaFragment : Fragment() {
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,…

Harol Rodriguez
- 189
- 1
- 2
- 11
15
votes
1 answer
Property in interface cannot have a backing field
I am learning Kotlin. My code is as follows:
interface BaseLogicDecoupler {
var notifier: A?
var router: B?
fun attachNotifier(notifier: A?) {
this.notifier =…

Krupal Shah
- 8,949
- 11
- 57
- 93
14
votes
7 answers
@Parcelize not resolved with androidExtensions experimental mode set to true
After switching to Gradle Kotlin DSL Gradle is not able to resolve @Parcelize annotation or package import kotlinx.android.parcel.Parcelize ("Unresolved reference" error). That happens with stable Kotlin plugin and latest Canary one. Build fails in…

marcinm
- 281
- 1
- 2
- 11
14
votes
1 answer
Android studio, strange error while building kotlin: wrong code generated
I'm trying for a few days to build my android project (contains mostly kotlin)...
I tried to change versions for everything, and I keep getting the same error while building!
The message I'm getting looks like this:
Kotlin…

Roi Amiel
- 353
- 1
- 3
- 18
14
votes
2 answers
Jetpack Navigation: NavHostManager is not an active fragment of FragmentManager
I'm using Jetpack Navigation for handling the navigation for Fragments.
I've been following the documentation and installed the required components, still the app just crash when trying to display the activity hosting the NavHost…

sallah kokaina
- 609
- 5
- 9
14
votes
3 answers
Disable META-INF/* generation in gradle android library kotlin project
Good day. I've written a kotlin android library and uploaded it on bintray. But when I try to use it (via gradle compile) in some project, it fails to build with following errors:
> com.android.build.api.transform.TransformException:…

arslancharyev31
- 1,801
- 3
- 21
- 39
14
votes
2 answers
What id name convention is good for Kotlin android extensions
Using Kotin android extensions I can avoid using findViewById, but
Im not sure how to name the ids to use it propertly.
I found two options are:
Use simple names for ids but then I can get in trouble with espresso if I use it with…

Daniel Gomez Rico
- 15,026
- 20
- 92
- 162
13
votes
2 answers
how to access member of outer class from inner class in Kotlin?
How to access the member of outer class from member function of inner class in kotlin. Consider the following code.
class A{
var name: String
class B{
fun show(){
print(name) //<----- here ide shows error. name…

Jaspal
- 601
- 2
- 13
- 23
13
votes
3 answers
How to use ViewModelProviders in Kotlin
I am new bie to Kotlin, Please help me how to use ViewModelProviders.of(this) in Kotlin
My code in java is
mFavViewModel = ViewModelProviders.of(this).get(FavouritesViewModel.class);
I am not able to find ViewModelProviders class in kotlin
tried…

Uma Achanta
- 3,669
- 4
- 22
- 49
13
votes
6 answers
Kotlin extension function start activity with Intent extras
I am trying to write a kotlin extension function for Context which will start a new activity in android with given class name and list of intent extras. I am able to successfully start activity without any extras but I am facing problem with…

Saksham Khurana
- 872
- 13
- 26
13
votes
5 answers
Android Kotlin .visibility
I have this code that is supposed to make an image visible, but I don't know exactly how it's supposed to be written for Kotlin.
I'm trying to use .visibility in Kotlin, and I don't know what to give it for a value. It's based off of…

StealthDroid
- 365
- 1
- 4
- 14
13
votes
4 answers
Android Kotlin : java.lang.NoClassDefFoundError: Failed resolution of:
Every second run of our android app, we get a crash that says
java.lang.NoClassDefFoundError: Failed resolution of: Lin/blahapp/xxx/BlahUtil
BlahUtil is a kotlin object with @JvmStatic annotations in it. I call these static methods from the rest…

letronje
- 9,002
- 9
- 45
- 53
12
votes
2 answers
Make Kotlin Serializer work with Retrofit
I cant make Kotlin Serializer work with Retrofit. I am using com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter:0.5.0 package along with Retrofit.
data classes
import kotlinx.serialization.SerialName
import…
user5539517