When I use ViewModel.Factory, appear `Kodein No binding found for bind()` errorR cannot be resolved - Android error'Must Override a Superclass Method' Errors after importing a project into Eclipse“Debug certificate expired” error in Eclipse Android pluginsHow do I fix “Failed to sync vcpu reg” error?LogCat message: The Google Play services resources were not found. Check your project configuration to ensure that the resources are includedError retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23Warning: This AsyncTask class should be static or leaks might occurAndroid Architecture Components, android binding and LiveDataDagger 2 - two instances of the same View model are createdKotlin Object saving into the Room Database with MVVM Design Pattern using Kodein
RPI3B+: What are the four components below the HDMI connector called?
How would my creatures handle groups without a strong concept of numbers?
Contexte et orthographe du mot « feedback »
What explains 9 speed cassettes price differences?
US Civil War story: man hanged from a bridge
What's the point of having a RAID 1 configuration over incremental backups to a secondary drive?
How to loop for 3 times in bash script when docker push fails?
Why isn't there research to build a standard lunar, or Martian mobility platform?
Is there any word for "disobedience to God"?
Why isn't pressure filtration popular compared to vacuum filtration?
Optimization terminology: "Exact" v. "Approximate"
Received a dinner invitation through my employer's email, is it ok to attend?
How can I get a player to accept that they should stop trying to pull stunts without thinking them through first?
Print the last, middle and first character of your code
Why did Harry Potter get a bedroom?
Is anyone advocating the promotion of homosexuality in UK schools?
Why presheaves are generalized objects?
Shortest hex dumping program
Why are they 'nude photos'?
Is a 10th-level Transmutation wizard considered a shapechanger for the purpose of effects such as Moonbeam?
Do I have a right to cancel a purchase of foreign currency in the UK?
How to properly say "bail on somebody" in German?
How were Martello towers supposed to work?
Good resources for solving techniques (Metaheuristics, MILP, CP etc)
When I use ViewModel.Factory, appear `Kodein No binding found for bind()` error
R cannot be resolved - Android error'Must Override a Superclass Method' Errors after importing a project into Eclipse“Debug certificate expired” error in Eclipse Android pluginsHow do I fix “Failed to sync vcpu reg” error?LogCat message: The Google Play services resources were not found. Check your project configuration to ensure that the resources are includedError retrieving parent for item: No resource found that matches the given name after upgrading to AppCompat v23Warning: This AsyncTask class should be static or leaks might occurAndroid Architecture Components, android binding and LiveDataDagger 2 - two instances of the same View model are createdKotlin Object saving into the Room Database with MVVM Design Pattern using Kodein
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I reference to http://kodein.org/Kodein-DI/?6.1/android#view-model-factory use the kodein viewmodel, appeared the error.
the part code
bind<ViewModelProvider.Factory>() with singleton KodeinViewModelFactory(instance())
class KodeinViewModelFactory(private val kodein: Kodein) : ViewModelProvider.Factory
override fun <T : ViewModel> create(modelClass: Class<T>): T =
kodein.direct.Instance(TT(modelClass))

add a comment |
I reference to http://kodein.org/Kodein-DI/?6.1/android#view-model-factory use the kodein viewmodel, appeared the error.
the part code
bind<ViewModelProvider.Factory>() with singleton KodeinViewModelFactory(instance())
class KodeinViewModelFactory(private val kodein: Kodein) : ViewModelProvider.Factory
override fun <T : ViewModel> create(modelClass: Class<T>): T =
kodein.direct.Instance(TT(modelClass))

add a comment |
I reference to http://kodein.org/Kodein-DI/?6.1/android#view-model-factory use the kodein viewmodel, appeared the error.
the part code
bind<ViewModelProvider.Factory>() with singleton KodeinViewModelFactory(instance())
class KodeinViewModelFactory(private val kodein: Kodein) : ViewModelProvider.Factory
override fun <T : ViewModel> create(modelClass: Class<T>): T =
kodein.direct.Instance(TT(modelClass))

I reference to http://kodein.org/Kodein-DI/?6.1/android#view-model-factory use the kodein viewmodel, appeared the error.
the part code
bind<ViewModelProvider.Factory>() with singleton KodeinViewModelFactory(instance())
class KodeinViewModelFactory(private val kodein: Kodein) : ViewModelProvider.Factory
override fun <T : ViewModel> create(modelClass: Class<T>): T =
kodein.direct.Instance(TT(modelClass))


asked Mar 26 at 2:14
Jie XuJie Xu
687 bronze badges
687 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It's quite simple, you just need to directly transfer Kodein to the factory, without instance()
class KodeinApp : Application(), KodeinAware
override val kodein by Kodein.lazy
import(androidXModule(this@KodeinApp))
bind() from singleton KodeinViewModelFactory(kodein)
bind() from singleton MyViewModel(kodein)
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348908%2fwhen-i-use-viewmodel-factory-appear-kodein-no-binding-found-for-bindkodein%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
It's quite simple, you just need to directly transfer Kodein to the factory, without instance()
class KodeinApp : Application(), KodeinAware
override val kodein by Kodein.lazy
import(androidXModule(this@KodeinApp))
bind() from singleton KodeinViewModelFactory(kodein)
bind() from singleton MyViewModel(kodein)
add a comment |
It's quite simple, you just need to directly transfer Kodein to the factory, without instance()
class KodeinApp : Application(), KodeinAware
override val kodein by Kodein.lazy
import(androidXModule(this@KodeinApp))
bind() from singleton KodeinViewModelFactory(kodein)
bind() from singleton MyViewModel(kodein)
add a comment |
It's quite simple, you just need to directly transfer Kodein to the factory, without instance()
class KodeinApp : Application(), KodeinAware
override val kodein by Kodein.lazy
import(androidXModule(this@KodeinApp))
bind() from singleton KodeinViewModelFactory(kodein)
bind() from singleton MyViewModel(kodein)
It's quite simple, you just need to directly transfer Kodein to the factory, without instance()
class KodeinApp : Application(), KodeinAware
override val kodein by Kodein.lazy
import(androidXModule(this@KodeinApp))
bind() from singleton KodeinViewModelFactory(kodein)
bind() from singleton MyViewModel(kodein)
answered Jun 22 at 17:40


Ivan TIvan T
1495 bronze badges
1495 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55348908%2fwhen-i-use-viewmodel-factory-appear-kodein-no-binding-found-for-bindkodein%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown