google-developer-training / basic-android-kotlin-compose-training-mars-photos

Solution code for Android Basics in Kotlin course
https://developer.android.com/courses/android-basics-kotlin/course?gclid=CjwKCAjw4c-ZBhAEEiwAZ105RTyT-iaLHzrhMBUXdMhO230ZDwOwxxI2x4RgK8DwBxK8t1h0wmU_QxoCi4YQAvD_BwE
Apache License 2.0
66 stars 58 forks source link

Add Repository #29

Open QoutNPC opened 1 year ago

QoutNPC commented 1 year ago

URL of codelab: https://developer.android.com/codelabs/basic-android-kotlin-compose-add-repository?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-5-pathway-2%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-add-repository#5

Specify the language of the codelab if it is not English: English

In which task and step of the codelab can this issue be found?

Add repository and Manual DI

[6. Add repository to ViewModel]

  1. Update the code to pass variable viewModel as an argument to the MarsPhotosApp composable. MarsPhotosTheme { val viewModel: MarsViewModel = viewModel(factory = MarsViewModel.Factory) MarsPhotosApp(viewModel) ## there is a mistake in this line }

Describe the problem

There is no parameter of "viewModel" in Function "MarsPhotosApp" as all the operations done in this course.

So it cannot run successfully.

Steps to reproduce?

  1. Go to...
  2. Click on...
  3. See error...

Versions Android Studio version:

Android Studio Dolphin | 2021.3.1 Patch 1 Build #AI-213.7172.25.2113.9123335, built on September 30, 2022 Runtime version: 11.0.13+0-b1751.21-8125866 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 5.15.0-58-generic GC: G1 Young Generation, G1 Old Generation Memory: 2048M Cores: 4 Registry: external.system.auto.import.disabled=true ide.text.editor.with.preview.show.floating.toolbar=false ide.instant.shutdown=false

Current Desktop: ubuntu:GNOME

API version of the emulator:

Additional information Include screenshots if they would be useful in clarifying the problem.

wngu6 commented 1 year ago

val viewModel: MarsViewModel = viewModel(factory = MarsViewModel.Factory) is supposed to be inside the MarsPhotosApp.kt file, just before the HomeScreen(marsUiState = viewModel.marsUiState). You can see this inside the main GitHub branch. The MarsPhotosApp() function should have no input arguments.

osuleymanova commented 1 year ago

Duplicate of #25, #20.