I've been trying to resolve my issue but I can't find anything...
MyApp.kt :
@HiltAndroidApp
class MyApp: Application()
MainActivity.kt
@AndroidEntryPoint
class MainActivity: AppCompatActivity()
MyFragment.kt
class MyFragment: Fragment() {
private val myViewModel: MyViewModel by viewModels()
}
MyViewModel.kt
class MyViewModel @ViewModelInject constructor(
application: Application,
myRepository: MyRepository, {*}
@Assisted private val state: SavedStateHandle,
): AndroidViewModel(application)
MyRepository.kt
interface MyRepository {
fun test()
}
class MyRepositoryImpl @Inject constructor(): MyRepository {
override fun test() { print("") }
}
MyModule.kt
@Module
@InstallIn(SingletonComponent::class)
abstract class MyModule {
@Binds
abstract fun bindsMyRepository(impl: MyRepositoryImpl): MyRepository
}
If I comment the line with "{*}", it works fine, but since I try to add my custom repository, I got this error :
java.lang.RuntimeException: Cannot create an instance of class MyViewModel
Caused by: java.lang.NoSuchMethodException: [class android.app.Application]
Do you have any idea of what I am missing?
Thanks you!
Complementary informations: I forgot to mention that this is a multi module app.
In the first module, there is the basic app : MainActivity, a manifest (1)
In the second module, there is the core app : MyApp, a manifest (2)
In the third module, there is the module : MyFragment, MyViewModel, MyRepository and MyModule, a manifest (3)
Manifests are like this:
(1)
<manifest...>
<application...
android:name=".secondModule.MyApp">
</manifest>
(2)
<manifest...>
<application>
<provider...></provider>
</application>
</manifest>
(3)
<manifest.../>