I am trying to use Dagger Hilt in order to inject a data class in my code. My goal is to be able to have a single data structure that I can inject everywhere.
I have defined a data class as below:
data class UserInfo @Inject constructor(
var lastname: String,
var firstname: String,
var email: String)
I have tried to use this data class in my MainActivity as below:
@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
@Inject
lateinit var userInfo: UserInfo
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
initValue()
}
fun initValue() {
userInfo.email = "ste@gmail.com"
}
I keep getting error like
public abstract static class SingletonC implements DriverApplication
I tried to add Singleton but it's also generating the issue.
I just try to have one single data class to store information and use this information everywhere in my code.
Any idea ?