Skip to content
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

Error occured in chapter 7 #19

Open
ghost opened this issue Aug 13, 2021 · 2 comments
Open

Error occured in chapter 7 #19

ghost opened this issue Aug 13, 2021 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 13, 2021

Where I get an error

Architectural Skeleton - MVVM News App Around 4:00

NewsActivity.kt. (onCreate function.)

override fun onCreate(SavedInstanceState: Bundle?){

......

val repository = NewsRepository(ArticleDatabase(this)
# In this line following error occured.
/*
Error
Type mismatch. 
Required: ArticleDatabase
Found:Unit
*/
}

I changed 'invoke' function in ArticleDatabase.kt as follows and it seems works without snag(I don't know it is right way or not though....)

operator fun invoke (context:Context) : ArticleDatabase {
return instance ?: synchronized(LOCK){
instance ?: createDatabase(context).also{ instance = it }
}

Thank you for your awesome videos and great instruction!!

@Mohamed-G1
Copy link

use dagger to inject ArticleDataBase class into RepositoryClass -> like that

@Inject
db : ArticleDataBase

@Aniket-parhate
Copy link

please help me i am also getting this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants