Property setter was expecting a com.google.appinventor.components.runtime.Button component but got a String instead

I followed a tutorial on youtube about a memory game but mine had errors.
I had this runtime error before I had this error it was this error:

Select list item: Attempt to get item number 0, of the list ["antartica.jpg", "northamerica.png", "northamerica.png", "laurasia.jpg", "africa.jpg", "asia.jpg", "asia.jpg", "australia.jpg", "africa.jpg", "southamerica.png", "pangea.jpg", "southamerica.png", "laurasia.jpg", "europe.jpeg", "europe.jpeg", "australia.jpg", "antartica.jpg", "gondwanaland.jpg", "gondwanaland.jpg", "pangea.jpg"]. The minimum valid item number is 1.
Note: You will not see another error reported for 5 seconds.

Then, when I change buttonIndex to 1 I got this already

Property setter was expecting a com.google.appinventor.components.runtime.Button component but got a String instead. Note: You will not see another error reported for 5 seconds.

clean up your blocks, then do a download blocks image.
Upload the png here.






blocks (7)

The last png is like the overall

I don't see the bug on my phone, and I won't have access to my PC till tomorrow.

But I recognize you are doing a matching game.

Search this board for Valentines Match , one of my samples.

Ok sir, Thanks

Here's a summary of the problem.

You keep two global variables that hold either a button component or a text blank

You don't check to see if they hold buttons before trying to compare their images.

Bulletproof the code.

Thank you sir, ill try to bulletproof the code

Sir Im really sorry but i dont know what to do im kinda new but I asked chatgpt it said that the problem may be the firstBtn and SecondBtn

sir is possible to just like hide the error because when I test it nothing wrong happens, like it just works good

You only set global firstBtn and global secBtn to a button component on the AnyButtonClicked event, whereas your clock timer tries to set properties to these two "buttons" when the variables are empty text blocks. I assume you clock timer starts when the app starts, before any buttons are clicked. You need to fix this.

1 Like

ok sir, ill try thank you

After sleeping on the problem, your screen switching may also be causing false firing of that clock Timer

sir is it possible to just hide the error or like its impossible

Hiding an error doesn't make it disappear. You should fix the error.

ok sir, thanks for the advice

At the beginning buttomindex is 0... it looks like the error is there. .

Aldo can you explain why you need all images twice in list imagesList?... your blocks look cumbersome...

Taifun

I followed a tutorial online sir, I am sorry sir I cannot really explain since im very new sir.

But are those blocks seem to be the problem sir because if it is then I will delete it, sorry sir im a very new sir.

Thank you to all who helped me