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!

Where Next?

Popular Pragmatic Bookshelf topics Top

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
raul
Hi Travis! Thank you for the cool book! :slight_smile: I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
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
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

Devtalk
Hello Devtalk World! Please let us know a little about who you are and where you’re from :nerd_face:
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
New
sir.laksmana_wenk
I’m able to do the “artistic” part of game-development; character designing/modeling, music, environment modeling, etc. However, I don’t...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New

Sub Categories: