1. What is the problem? Be very detailed.
I think I found a bug. Attached is a minimal form with two languages (English (en) and Bavarian (bar)), three fields in a group, one of them has an image label. Included is the .odkbuild save file which will work on ODK Build 0.4.0 (currently running at https://tom.build.getodk.org/).
When I change the language inside the form, Collect crashes and goes to the main menu.
When I open a new form, the default language is the first by alphabetic order - Bavarian. When I change the language to English, Collect crashes again.
2. What app or server are you using and on what device and operating system? Include version numbers.
ODK Collect v2021.3.2 on Vivo 1937, Android 10 / Funtouch OS 10
ODK Central 1.3.0
3. What you have you tried to fix the problem?
TODO: shrink the form to MVE. My bottleneck: available time.
4. What steps can we take to reproduce the problem?
Deploy the attached XForm to Central, attach the two media images, test on Collect. Try and get the form to show English.
5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.
Forms: Collect0crash.zip (1.7 KB)
Hi @Florian_May
Thanks for the form. I was able to reproduce the crash so I'm going to investigate it. Could you maybe attach xls version of your form not only xml? If you don't have it that's fine just let me know.
How did you produce your xml form? Did you add anything manually?
I'm asking because if I take that xml form I can reproduce the crash but if I convert the xls version using https://getodk.org/xlsform/ and use then everything seems to be fine so I guess there is something spoiled in the xml form. I'm wondering if ODK Build adds something incorrect or maybe you have added something manually?
I've built the form in ODK Build, testing out the new media labels, then exported it straight to XML and XLS (using build2xlsform). Media labels come from the latest additions to Build, so maybe Build produces invalid XML?
Edit: just checked and saw that build2xlsform does not support media labels yet (will add), so the xls will not crash.
Deleting the "short" label makes the form work with media labels (attached as Test040_noshort_works.xml). I think this means that ODK Build 0.4.0 does not produce invalid XML for media labels then. Test040_noshort_works.xml (5.4 KB)
Removing the media labels and only leaving the field with a label (bar) and a label&short (en) still produces the crash. Test040_nomedia_onlyshort.xml (5.3 KB)
This gets wilder.
Since Bavarian is the first language in the XML (in which languages seem to be sorted A-Z although in Build English comes first and Bavarian was added), a form with a short for Bavarian and no short for English does not crash, but shows the Bavarian short title in place of the English one. Test040_bar_short.xml (5.4 KB)
TLDR:
The above tells me that the crash is caused by the presence of a short label in a field the second language for which the first language has no short label.
Forms with consistent use of short labels seem not to crash.
Sorry for the late response but I was on a sick leave.
Thanks for all those details!
I've investigated your form and I agree that the crash is caused because one of your languages has translation for short label and the second one doesn't and the problem here is that it completly lacks that element in xml form but it should exists, just holds an empty value.
If you support multiple languages the first one (in xml form) is treated as the default one (Bavarian in your case) and when you open that form for the first time it is used.
If other translations (English in your case) have translations for elements that the first language lacks (no matter if those are translations for label or short label) you will end up with that crash (NoLocalizedTextException in javarosa).
So to solve your problem please add all that translations in the same way or remove those that exist only in some languages (non default)
I don't think it's something we should handle in Collect or Javarosa it's nothing new.
I think it's a bug in ODK build, why? Because if you don't have translations for some elements those elements should still be present in xml form but with empty values. ODK Build handles that case correctly if you for example do the same for normal labels but somehow for short labels it ignores that element in xml form at all.
If you build a form using xls you are also protected because missing translations will be represented as -
So to sum up the issue might take place only if you build a form using ODK Build (or manually edit your xml file) and only if you use that short label.
BTW what's that short label for? Is there any pleace in ODK Collect where it is used?