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 Pragmatic topics Top

kuroneko
Whilst the author has been careful to provide exact results for the tests elsewhere in the book (such as surds with the transformation te...
New
conradwt
First, the code resources: Page 237: rumbl_umbrella/apps/rumbl/mix.exs Note: That this file is missing. Page 238: rumbl_umbrella/app...
New
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
jskubick
I’m under the impression that when the reader gets to page 136 (“View Data with the Database Inspector”), the code SHOULD be able to buil...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
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
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
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
New
New
wmnnd
Here’s the story how one of the world’s first production deployments of LiveView came to be - and how trying to improve it almost caused ...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
New
AstonJ
This is a very quick guide, you just need to: Download LM Studio: https://lmstudio.ai/ Click on search Type DeepSeek, then select the o...
New

Latest in PragProg

View all threads ❯