keno.basedow

keno.basedow

Kotlin and Android Development featuring Jetpack: Cannot find identifier 'basicAI' (version B4.0 page 78)

Hello Michael,

i have problems with this line on page 78 in version B4.0:

android:entries=“@{AI.basicAI}”

it shows the error message:

Cannot find identifier ‘basicAI’

I solved the problem changing the line to:

android:entries=“@{AI.getBasicAI()}”

I found the solution on the internet page in the answer of [dominicoder]:

I used Tools > Kotlin > Show Kotlin Bytecode > Decompile to take a look how java has encoded the property.

Am i on the right path? Or do i have any other kind of problem?

I am using Android Studio 4.1.1 and these library versions:

kotlin_version = “1.4.21”
gradle_version = “4.1.1”
app_compat_version = “1.2.0”
constraint_layout_version = “2.0.4”
core_version = “1.3.2”
lc_version = “2.2.0”
nav_version = “2.3.2”

Best regards

Keno Basedow

Marked As Solved

mfazio23

mfazio23

Author of Kotlin and Android Development featuring Jetpack

Hey Keno!
You’re definitely on the right path here, but the error in Android Studio about not being able to find AI.basicAI is incorrectly flagged. That being said, I like using AI.getBasicAI() to avoid this kind of confusion.

Looking at the Java code is the right approach as Kotlin properties are converted in the fashion you saw. This means properties of a Kotlin class are accessed on the Java side by get()/set() methods.

I’m going to switch up the code and include a little note explaining the difference here. Thanks!

Popular Prag Prog topics Top

belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
New
simonpeter
When I try the command to create a pair of migration files I get an error. user=> (create-migration "guestbook") Execution error (Ill...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
hazardco
On page 78 the following code appears: <%= link_to ‘Destroy’, product, class: ‘hover:underline’, method: :delete, data: { confirm...
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
mcpierce
@mfazio23 I’ve applied the changes from Chapter 5 of the book and everything builds correctly and runs. But, when I try to start a game,...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

AstonJ
Or looking forward to? :nerd_face:
New
Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
New
AstonJ
Chris Seaton, the creator of TruffleRuby has died. It appears from suicide :cry: He left this note on Twitter on the weekend: And one...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New

Latest in PragProg

View all threads ❯