Moving my comment to an answer:
If you have a constructor with default arguments, Kotlin actually generates additional constructors. In your case, you have a 3 arg constructor where all are optional, which generates a total of 4 constructors. Kotlin apparently associates any annotations on the primary constructor with all the generated ones as well, which means you ended up with 4 @Inject
constructors.
You have two options:
The first, as you mentioned yourself, remove all the default values. If there are no default values, only one constructor is generated with the annotation.
Alternatively, you can also create additional constructors yourself and point it to the primary. This would also let you manually specify only one to have the @Inject
annotation, while the others don't. Basically:
data class AuthDataModel @Inject constructor(
var username: String,
var password: String,
var mobileData: String) {
constructor(username: String) : this(username, "", "") {}
constructor(username: String, password: String) : this(username, password, "") {}
}
Not using default values prevents multiple @Inject constructors from being generated, and the secondary constructors should1 keep everything functioning as expected. This is basically overloading the constructor, and it's equivalent to what you'd do in Java when certain variables are optional. Should therefore be fine.
1: I haven't done Android in a while, and I've never used @Inject. If option 2 doesn't work (as in @Inject doesn't allow it, or doesn't work as expected, etc.), that only leaves option 1, and requires every parameter to be explicitly passed. The secondary constructors calling the primary constructor should be enough to keep everything working, though.