Felipe Passos
04/27/2021, 11:01 AMColton Idle
04/27/2021, 11:19 AMColton Idle
04/27/2021, 11:20 AMFelipe Passos
04/27/2021, 11:22 AMFelipe Passos
04/27/2021, 11:23 AMdependencies {
classpath 'com.android.tools.build:gradle:7.0.0-alpha14'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.31"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.35"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
and in the app build file:
implementation "com.google.dagger:hilt-android:2.35"
implementation "androidx.hilt:hilt-navigation-compose:1.0.0-alpha01"
Added this line to the main file:
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val _tag = "TAXI"
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
and on the navHost :
@Composable
fun SearchNavigator(location: String) {
val navController = rememberNavController()
Log.d("LOCATION_IN_NAV", location)
Column(
modifier = Modifier
.background(white)
.padding(vertical = 10.dp)
.fillMaxHeight()
.fillMaxWidth()
) {
NavHost(navController, startDestination = "MainSearch") {
composable("MainSearch") { backStackEntry ->
val viewModel = hiltNavGraphViewModel<LocationViewModel>(backStackEntry = backStackEntry)
Log.d("LOCATION_IN_SEARCH", viewModel.name.hasObservers().toString())
Form(location, navController)
But i'm getting a runtime error saying that the AndroidEntryPoint is not setted :
2021-04-27 07:52:57.310 10438-10438/com.gotootaxi E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.gotootaxi, PID: 10438
java.lang.IllegalStateException: Given component holder class com.gotootaxi.MainActivity does not implement interface dagger.hilt.internal.GeneratedComponent or interface dagger.hilt.internal.GeneratedComponentManager
at dagger.hilt.EntryPoints.get(EntryPoints.java:62)
What i'm doing wrong?Adam Powell
04/27/2021, 1:21 PMlocation
won't be applied.Adam Powell
04/27/2021, 1:22 PMval currentLocation by rememberUpdatedState(location)
as the first line of the SearchNavigator function, then use currentLocation
instead of location
everywhere else in your snippet.Adam Powell
04/27/2021, 1:23 PMFelipe Passos
04/27/2021, 1:44 PMFelipe Passos
04/27/2021, 1:44 PMAdam Powell
04/27/2021, 1:49 PMJeremy Woods
04/27/2021, 3:43 PM