HTML Dropdown does not show

Hi,

I am upgrading ODK Table from version 2.0.6 to 2.1.6. I got the issue where a simple dropdown in html form does not show when I touch it. This is the html:

<!DOCTYPE html>
<html>
<body>
<h1>The select element</h1>
<p>The select element is used to create a drop-down list.</p>
<form>
      <label for="cars">Choose a car:</label>
      <select name="cars" id="cars">
           <option value="volvo">Volvo</option>
          <option value="saab">Saab</option>
          <option value="opel">Opel</option>
          <option value="audi">Audi</option>
      </select>
<input type="submit" value="Submit">
</form>
</body>
</html>

The issue only happens on Android 5.0/5.1 and on ODK Tables 2.1.6. When I run the form in ODK Tables 2.0.6, the issue is gone regardless of Android version.

Do you have any thoughts around the root cause?

Hi @Thien_Mai,

I’m able to reproduce this using the Android Emulator on version 5.1 (Google API). select elements in Survey doesn’t work either. I’ve opened an issue on our issue tracker. Tables/Survey crash with HTML select on Android 5.1 · Issue #196 · odk-x/tool-suite-X · GitHub

As a workaround, could you try updating the webview through Google Play?

2 Likes

Thanks @linl3
I updated webview to version 88 in Google Play. It did not work.

1 Like

Hi @linl33 ,

I found this log when the issue happens, hopefully it helps

W/WindowManager: Attempted to add window with non-application token WindowToken{1d149669 null}. Aborting.

Also, I found this code causing the issue:

org.opendatakit.views.ODKWebView

private static Context getFixedContext(Context context) {
return VERSION.SDK_INT >= 21 && VERSION.SDK_INT < 23 ? context.createConfigurationContext(new Configuration()) : context;
}

I know the logic here is to fix something related to Android 5.0/5.1. I managed to always return context instead of createConfigurationContext(), then the SELECT dropdown shows as normal.

1 Like

Thanks for looking into this issue!
@W_Brunette Do you remember why that was added for 5.0 and 5.1?

For reference this is the commit for that change, https://github.com/odk-x/androidcommon/pull/97

1 Like

If I remember correctly, it was when we upgraded to 9 and started to change the app-compat libraries to Androidx. This stackoverflow post helped to jog my memory. The post also has an update that the problem in app-compat was fixed in 2020, so the Dec 2020 release probably pulled in this changed behavior.

1 Like

Thanks @W_Brunette.

The trace you give makes the issue much clearer to me. It is not quite an easy fix I guess. Do you have any advice on how to bypass the issue by upgrading something? Or the estimate on when the fix is rolled out?
I will have to downgrade to ODK Tables 2.1.4 (and ODK Services as well) on android 5 devices. I tested this version and the issue does not happen. Is there any caution that I should take on 2.1.4?

2 Likes

@Thien_Mai. We plan to do a release around the end of March. I think your solution may be correct, but we need to test on other versions. You can help us out by testing your solution on other versions.

2 Likes

That’s great. I am happy to test the fix. Thanks.

1 Like

@Thien_Mai After you test it on other versions feel free to open a pull request against the development branch and I will start testing it as part of the release.

1 Like

@W_Brunette, Unfortunately I am not able to build it, trying many times

Could not get resource ‘https://jcenter.bintray.com/org/opendatakit/snapshotBasicAndroidlibrary/maven-metadata.xml’.
> Could not GET ‘https://jcenter.bintray.com/org/opendatakit/snapshotBasicAndroidlibrary/maven-metadata.xml’. Received status code 500 from server: Internal Server Error

It seems that jcenter is down.

1 Like

@Thien_Mai, androidlibrary is hosted on a different server: http://cwe.cs.washington.edu:8082/artifactory/webapp/home.html?.

You can check out androidlibrary in your same folder same with androidcommon as services, tables, and survey look first at the same folder first before going to the web.

1 Like

@W_Brunette, I could build the apk and tested. It worked on the device which occurs the issue previously and on all devices I have (android 4, 7, 8, 10).

What was tested: All forms in my real project not crash, dropdown showed perfectly, sync function worked well.

Regarding the pull request, I don’t know how to correctly handle the ticket to get aligned with your project development, so I attach the patch here.

I wanted to completely remove odkContext, but because this is common lib and I could not verify all its dependents, so I had to keep getOdkContext() method, which is not really great.

2 Likes

dropdown-fix.txt (2.8 KB)
patch uploaded.

2 Likes

@Thien_Mai can you open a GitHub Pull Request that applies your fix to the development branch of the ODK-X repo?

Pull Requests are the standard way we make changes to ODK-X.

A pull request has been raised.

2 Likes

@Thien_Mai the preview release of version 2.1.8 is now available that should fix your issue. Can you give us a try and let us know by end of the week?

1 Like

Hi @W_Brunette, it works like a charm. Thanks a lot.

2 Likes

what was the exact issue ? how did you resolved it?. .

1 Like