I have the following Kotlin Class:
@ExperimentalCoroutinesApi
class SharedPrefClient
@Inject constructor(private val prefs: SharedPreferences)
: SharedPreferences by prefs {
...
}
In Dagger, I get the following error while building the project:
But it workes when I remove the class Delegation : SharedPreferences by prefs
Now my question is how can I use Dagger and Kotlin Class Delegation both together.

It seems to me that the problem is with
android.annotation.Nullablewhich gets pulled into your code by using thebykeyword, but which isn't accessible from outside the Android source code.Usually you'd see the error directly if the type cannot be resolved, but in this case Kotlin generates Java code with the unknown annotation and Dagger tries processing that, leading to your error.
If you create your own interface other than
SharedPreferencesit will work just fine as you'd expect.You might be able to add
android.annotation.Nullableto your (compile only) classpath somehow so that Dagger can do its thing, but it's probably easier to find another way.I see three issues that you could raise here