google-developer-training / android-basics-kotlin-cupcake-app

Apache License 2.0
103 stars 163 forks source link

Listener bindings - part of #6 #60

Closed ScottMal69 closed 2 years ago

ScottMal69 commented 2 years ago

URL of codelab https://github.com/google-developer-training/android-basics-kotlin-cupcake-app

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

6 - Adding android:onClick="@{()...." to radio buttons on the fragment_flavor.xml layout.

Describe the problem If you select any flavor (I selected "salted caramel", the app terminates with this exception: java.lang.IllegalStateException: Could not find method @{() -> viewModel.setFlavor(@string/salted_caramel)(View) in a parent or ancestor Context for android:onClick attribute defined on view class com.google.android.material.radiobutton.MaterialRadioButton with id 'salted_caramel'

Steps to reproduce?

  1. Add the listener bindings to the fragment_flavor.xml layout
  2. Build and run the app
  3. Select a quantity on 1st fragment screen
  4. Select ANY flavor on the 2nd fragment screen
  5. You'll get the above error

Versions Studio Build: AI-211.7628.21.2111.8193401 Version of Gradle Plugin: 7.1.2 Version of Gradle: 7.2 Version of Java: Could not find a JAVA version anywhere, but found this: default JDK: 11.0.11 OS: Windows 10 Kotlin Plugin: JetBrains 211-1.6.10-Release-923-AS7442.40

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

ScottMal69 commented 2 years ago

Typo error...found it! Sorry...