Kotlin and Android Development featuring Jetpack: @string/na error (version B4.0 page 91)

Hi Michael,

line

android:text=’@{vm.currentPlayer.playerName ?? @string/na}’

produces error

…\PennyDrop\app\build\generated\source\kapt\debug\de\basedow\keno\pennydrop\databinding\FragmentGameBindingImpl.java:503: error: cannot find symbol
vmCurrentPlayerPlayerNameJavaLangObjectNullTextCurrentPlayerNameAndroidStringNaVmCurrentPlayerPlayerName = ((vmCurrentPlayerPlayerNameJavaLangObjectNull) ? (textCurrentPlayerName.getResources().getString(R.string.na)) : (vmCurrentPlayerPlayerName));
^
symbol: variable na
location: class string

i replaced it by

android:text=’@{vm.currentPlayer.playerName ?? “”}’

Kind regards Keno

Thanks Keno - this one isn’t actually an error since I mention the fallback resource value. However, I wasn’t super clear on what I meant there, so I’ve included an extra note about what exactly to add:

In case we don’t have a value for currentPlayer (like before a game’s been started), we’re also going to add a fallback string resource value called na (with the value “N/A”).

Oh, i did not got the point that i should have created my own resource name “na”.