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

RUN migration-to-hilt Crash ? #103

Open
lwns opened this issue Jan 4, 2021 · 1 comment
Open

RUN migration-to-hilt Crash ? #103

lwns opened this issue Jan 4, 2021 · 1 comment

Comments

@lwns
Copy link

lwns commented Jan 4, 2021

Process: com.fernandocejas.sample.dev.debug, PID: 8024
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fernandocejas.sample.dev.debug/com.fernandocejas.sample.features.movies.MoviesActivity}: java.lang.RuntimeException: Cannot create an instance of class com.fernandocejas.sample.features.movies.MoviesViewModel
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.RuntimeException: Cannot create an instance of class com.fernandocejas.sample.features.movies.MoviesViewModel
at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:221)
at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:278)
at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.java:106)
at androidx.hilt.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:69)
at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:69)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:185)
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:54)
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:41)
at com.fernandocejas.sample.features.movies.MoviesFragment.getMoviesViewModel(Unknown Source:2)
at com.fernandocejas.sample.features.movies.MoviesFragment.onCreate(MoviesFragment.kt:49)
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2685)
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187)
at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1255)
at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1138)
at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:136)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2001)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2641)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
at android.app.Activity.performStart(Activity.java:7029)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2741)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 
Caused by: java.lang.InstantiationException: java.lang.Class<com.fernandocejas.sample.features.movies.MoviesViewModel> has no zero argument constructor
at java.lang.Class.newInstance(Native Method)
at androidx.lifecycle.ViewModelProvider$NewInstanceFactory.create(ViewModelProvider.java:219)
at androidx.lifecycle.ViewModelProvider$AndroidViewModelFactory.create(ViewModelProvider.java:278) 
at androidx.lifecycle.SavedStateViewModelFactory.create(SavedStateViewModelFactory.java:106) 
at androidx.hilt.lifecycle.HiltViewModelFactory.create(HiltViewModelFactory.java:69) 
at androidx.lifecycle.AbstractSavedStateViewModelFactory.create(AbstractSavedStateViewModelFactory.java:69) 
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:185) 
at androidx.lifecycle.ViewModelProvider.get(ViewModelProvider.java:150) 
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:54) 
at androidx.lifecycle.ViewModelLazy.getValue(ViewModelProvider.kt:41) 
at com.fernandocejas.sample.features.movies.MoviesFragment.getMoviesViewModel(Unknown Source:2) 
at com.fernandocejas.sample.features.movies.MoviesFragment.onCreate(MoviesFragment.kt:49) 
at androidx.fragment.app.Fragment.performCreate(Fragment.java:2685) 
at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:280) 
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187) 
at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1255) 
at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1138) 
at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:136) 
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:2001) 
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1959) 
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1861) 
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2641) 
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2589) 
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247) 
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541) 
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210) 
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334) 
at android.app.Activity.performStart(Activity.java:7029) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2741) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
at android.app.ActivityThread.-wrap11(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6494) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

@Zhuinden
Copy link

Zhuinden commented Jan 4, 2021

Did you forget to add @AndroidEntryPoint to MoviesFragment?

Did you forget to apply the Android Dagger Hilt Plugin?

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