Bug? [workaround] (B4A/B4J) "The given key was not present in the dictionary"

aeric

Expert
Licensed User
Longtime User
Today I found a weird situation when I tried to open my MiniORMUtils project.
I am getting the error:

An error occured.
Error loading file.
The given key was not present in the
dictionary.


I am using B4A v13.50 under Windows 11. This error also happens in B4J v10.50.
I tried opening the same project under Linux Mint (under VM) but there is no error.
If I make a copy of the project file .b4a or .b4j and open it, there is no error!

If you are also facing the same issue, my workaround:
  1. Make a copy of the project file
    OR
  2. Delete .b4a.meta or .b4j.meta
    OR
  3. Add a # at the first line of .b4a.meta or .b4j.meta
Then your project should be opened without errors.

I attach my project in this post.
 

Attachments

  • source.zip
    387.5 KB · Views: 1
Last edited:

aeric

Expert
Licensed User
Longtime User
I suspect this is something related to the .meta file is "UTF8 contains BOM" formatted.
When I was creating my configure-b4x-wine.sh script to read and write the b4xV5.ini file, the script has issue to read the first "AdditionalLibrariesFolder" key.
When I asked Qwen AI chatbot, it said that this is due to the Windows UTF-8 BOM (Byte Order Mark) issue.

Aeric:
No, it only happens when the first key is "AdditionalLibrariesFolder" and not other key like "AutoBackup". It also work normally if first line is a comment.

Qwen:
You've perfectly pinpointed the symptom of a Windows UTF-8 BOM (Byte Order Mark) issue.

When B4A/B4J creates b4xV5.ini, it often writes it as UTF-8 with BOM. The BOM (EF BB BF) is invisible but sits at the very start of the file. If AdditionalLibrariesFolder is the first key, the line actually looks like this to grep/sed: <BOM>AdditionalLibrariesFolder=... Your grep "^AdditionalLibrariesFolder=" fails because ^ doesn't match the invisible BOM bytes. If a comment is first, line 1 is the comment, and line 2 has no BOM, so it works.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…