Web1 JsonTextDecodeWithDictionaries Runtime Error java.lang.String cannot be cast to com.google.appinventor.components.runtime.util.YailDictionary

That must have something to do with what you are doing after setting global MyDict with the data.

1 Like

Where can one find the 'Is Dictionary empty' block?

As I said above, there isn't one. The isListEmpty block (in Lists blocks) should do it OK

1 Like

After setting up the global MyDict, I only use the MyDict data (regardless of whether it's the first or second run of my application - i.e. the code is the same every time I run my application) to display the text of the UI elements in the appropriate language.
So, if the code doesn't change on any run of my application, i.e. it works the same, then I don't understand why it doesn't work on the first run of my application (when the text elements from my MyDict dictionary need to appear on the elements), and why it works on the second, third, etc. run of my application (when the text elements from my MyDict dictionary also need to appear on the elements)?
Since the code is the same, I thought that this error (that the texts do not appear on the first run, but only on the second run) might be due to a timing problem. No?

I have made you a simple example:

readJsonToDict.aia (16.9 KB)

1 Like

Did you move the code after the MyDict load into the new Initialization phase 2 procedure I mentioned earlier?

You will still have two places in the startup code where that would be called

  • In Screen Initialize after seeing MyDict is ready
  • In File 1.GotText after making MyDict ready

This can't work without the procedure and the two calls.

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
export_and_upload_aia

As I have clearly shown in my example aia...

2 Likes

Thank you all very much for your help!

I don't understand why the call_TinyDB1_ClearTag_tag_dictTranslator block is there?
call_TinyDB1_ClearTag_tag_dictTranslator

For testing only, so you do not have restart the companion when testing a "first run"

1 Like

I usually wrap loose blocks like that in procedure definitions to avoid a yellow error.

Then I apply a Do It to the block inside to run it.

1 Like

When I try to do it in the 'set values ​​do' block on the 'select list item list' block, I get the following error message:


What am I doing wrong?

You are trying to run a Do It on blocks that refer to local variables.

The local variables are long gone by the time you get to apply the Do It.

To debug code like this, you can add extra global variables with names like debug_values, and inside the local init, set global debug_values to local values, then have the other blocks in that scope refer to global debug_values.

This makes the guts of the procedure testable with Do It, at the expense of having extra wires and tubes hanging out of it. After you are finished with your Do It testing, you can close it up by reversing the global hookups and removing the global variable.

1 Like