Questions tagged [kotlin-android-extensions]

Questions related to Kotlin Android Extensions

Kotlin Android Extensions

721 questions
66
votes
13 answers

Kotlin Android debounce

Is there any fancy way to implement debounce logic with Kotlin Android? I'm not using Rx in project. There is a way in Java, but it is too big as for me here.
64
votes
4 answers

Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found

apply plugin: 'kotlin-android-extensions'. When i add this extensions in android studio preview, give me this error "Error:(1, 0) Plugin with id 'kotlin-android-extensions' not found.". My build gradle apply plugin:…
53
votes
12 answers

Unresolved reference: viewModelScope - Kotlin Android

I try to add viewModelScope to a basic viewModel but android studio doesn't recognize it. I tried to change my gradle build file with some solution I found but nothing works. Here an extract of my build.gradle app implementation…
51
votes
3 answers

This type has a constructor and must be initialized here - Kotlin

I just get started experimenting Android app using Kotlin. I just wanted to inherit Application class like this: class SomeApp : Application { } But the compiler raises the warning: and suggestion changes it to: class SomeApp : Application() { …
Krupal Shah
  • 8,949
  • 11
  • 57
  • 93
49
votes
10 answers

Unresolved reference for synthetic view when layout is in library module

using Kotlin 1.20.20 (not that it matters, older versions behaves the same) When layout is in separate library module Android Studio has no problem finding and referencing the view import kotlinx.android.synthetic.main.view_user_input.* But when I…
Martynas Jurkus
  • 9,231
  • 13
  • 59
  • 101
47
votes
2 answers

Identity equality for arguments of types Int and Int is deprecated

Just fyi, this is my first question on StackOverflow and I'm really new in Kotlin. While working on a project that's fully Kotlin (ver 1.1.3-2), I see a warning on the following code (with the comments for you curious lads): // Code below is to…
Aba
  • 2,307
  • 2
  • 18
  • 32
46
votes
2 answers

Understanding Kotlin's yield function

I don't see a very clear definition of the yield function in Kotlin. Example in the link above doesn't mention much but the following, val sequence = sequence { val start = 0 // yielding a single value yield(start) // yielding an…
Ahmed
  • 2,966
  • 7
  • 42
  • 69
46
votes
7 answers

MockK "io.mockk.MockKException: no answer found for:" error

Hi i am trying to mock the response i get from a Single observable that gets returned from retrofit using a delegator that my presenter class calls and i am getting the following error: io.mockk.MockKException: no answer found for:…
Jono
  • 17,341
  • 48
  • 135
  • 217
44
votes
8 answers

How to pass the values from activity to another activity

As I'm learning Kotlin for Android development, I'm now trying the basic programs like hello world and how to navigate from one activity to another activity, there is no issue with this. When I move from one activity to another, it works fine, but I…
Jeyaseelan
  • 571
  • 1
  • 4
  • 14
43
votes
5 answers

Can't set visibility on constraint group

When i try to set the visibility of the group on button click,it doesn't affect the view's visibility.Using com.android.support.constraint:constraint-layout:1.1.0-beta4. I've tried setting it element-wise without problems,but no success with the…
40
votes
3 answers

Deep copy of list with objects in Kotlin

I am new to kotlin and I am trying to make a copy of a list of objects.The problem I am having is that when I change items in the new copy, the old list gets changed as well. This is the object: class ClassA(var title: String?, var list:…
Oya
  • 833
  • 1
  • 8
  • 21
37
votes
6 answers

com.android.tools.r8.errors.CompilationError: Program type already present: androidx.annotation.AnimRes

I'm trying to rebuild my project which I've written in kotlin but it has constantly failed with the error Program type already present: androidx.annotation.AnimRes I've tried Invalidating cache cleaning and rebuilding using ./gradlew build…
32
votes
1 answer

Kotlin - Set @Annotations . to function return types?

Is there a way to use annotations to declare a return condition for kotlin functions? For example, I want to tell lint that my function will return an Android resource id at: fun getImageId(): Int I would want something as: fun getImageId():…
htafoya
  • 18,261
  • 11
  • 80
  • 104
32
votes
6 answers

Kotlin Android View Binding: findViewById vs Butterknife vs Kotlin Android Extension

I'm trying to figure out the best way to do Android View Binding in Kotlin. It seems like there are a few of options out there: findViewById val button: Button by lazy { findViewById
triad
  • 20,407
  • 13
  • 45
  • 50
30
votes
10 answers

Kotlin synthetic and custom layout in DialogFragment

Let's say I have this layout:
Geob-o-matic
  • 5,940
  • 4
  • 35
  • 41
1
2
3
48 49