-
-
Notifications
You must be signed in to change notification settings - Fork 694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android Studio complains that by viewModel is an unresolved reference #1498
Comments
can you extract your ViewModel class declaration outside, to check? |
Do you mean to a separate file? The bulk of our view models are defined in different files or rarely other gradle modules. You can see in the first file that the view model is declared in another file. It doesn't complain that the view model is the wrong type, since in Fragments I can use the same VM class. It's only activities which show this error. |
really weird 🤔 Is it a project config issue? Can you try checkout this tutorial: https://insert-koin.io/docs/quickstart/android-viewmodel |
I have the same issue, but I'm using the vanilla by viewModels from androidx. I think this is an android studio bug. If I move my implementation dependencies a bit the issue disappears... |
Same problem here, code works fine but AS reports error 😞 @ForceTower what do you mean by moving implementation dependencies? |
Sometimes l just need to go to my grade file and move the dependencies around and that fixes the issue... |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Seems to have resolved with current versions of android studio. |
Android studio reports an error in the code when using
by viewModel()
in an AppCompatActivityTo Reproduce
See attached snip of our app.
Simply creating an activity which extends AppCompatActivity reports a compilation error.
Note that the project compiles just fine.
This occurs on several versions of Android Studio, currently using a mix of Chipmonk, Dolphin, and Eel.
Expected behavior
Android studio doesn't report and error.
Koin project used and used version (please complete the following information):
The text was updated successfully, but these errors were encountered: