It seems to me that the problem is with android.annotation.Nullable
which gets pulled into your code by using the by
keyword, 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 SharedPreferences
it will work just fine as you'd expect.
You might be able to add android.annotation.Nullable
to 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
- Dagger should fail better. The error message is of little help in this case
- Android shouldn't expose internal/hidden types,
- and/or Kotlin shouldn't pull in those hidden types