android / android/testing-samples
Native NullReferenceException thrown on ByMatcher.java:142 when using Android 4.4.x devices.
- Dominant language
- Java
- Stars
- 9.3k
- Forks
- 3.6k
- PR merge metrics
- No merged PRs in 30d
Description
Hi everyone,
I'm trying to include an Android 4 device for my Automation suite, but for some reason I'm seeing NullReference exceptions when interacting with certain textboxes in an app under test but ONLY when using pre-Android 5 devices.
The stack traces I'm seeing are as follows:
`java.lang.NullPointerException
at android.support.test.uiautomator.ByMatcher.findMatches(ByMatcher.java:142)
at android.support.test.uiautomator.ByMatcher.findMatches(ByMatcher.java:111)
at android.support.test.uiautomator.ByMatcher.findMatches(ByMatcher.java:96)
at android.support.test.uiautomator.UiDevice.findObjects(UiDevice.java:171)`
when using FindObjects method to look for the textbox in question or:
`java.lang.NullPointerException
at android.support.test.uiautomator.ByMatcher.findMatches(ByMatcher.java:142)
at android.support.test.uiautomator.ByMatcher.findMatches(ByMatcher.java:111)
at android.support.test.uiautomator.ByMatcher.findMatch(ByMatcher.java:72)
at android.support.test.uiautomator.UiDevice.hasObject(UiDevice.java:154)
at android.support.test.uiautomator.Until$2.apply(Until.java:55)
at android.support.test.uiautomator.Until$2.apply(Until.java:52)
at android.support.test.uiautomator.WaitMixin.wait(WaitMixin.java:40)
at android.support.test.uiautomator.WaitMixin.wait(WaitMixin.java:34)
at android.support.test.uiautomator.UiDevice.wait(UiDevice.java:187)`
when using phone.wait(Until.hasObject(By.res(identifier)), timer); for example.
Any clues on how to bypass this issue? I'm not sure if our App developers are doing something strange with these textboxes or early Android versions are just poorly supported by UiAutomator.
Contributor guide
Research direction
Start by reproducing the failure on a pre-Android 5 device through UiDevice.findObjects and wait(Until.hasObject(By.res(identifier))). Then inspect ByMatcher.java:142 and its callers to determine why the null value occurs; done means documenting a reliable workaround or providing a fix validated against both affected call paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100