I have a test suite that open JSON files. The tests do not pass on emulator <= API 23 and work fine on newer API Level.
There are two different kinds of exceptions:
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated string at line 1 column 1025 $.ajsonelement
and
com.google.gson.JsonSyntaxException: java.io.EOFException: End of input at line 1 column 1025 path $.ajsonelement.
The weird thing is that those files work fine when I run the app and open them manually in the simulator.
I'm using gson but the problem also appears with Moshi.
Found the issue. The json files were in
moduleName/src/test/resources/configs/. I moved them tomoduleName/src/test/assets/configs/The code to load them was:
I replaced it with a Guava helper:
Everything loads fine for all emulator between API 18 and 26.