getodk/javarosa

String.join not available in lower Android levels

Closed this issue · 5 comments

03073d4#diff-111bb41e949053901319c1fb810b853aR749 uses String.join which was introduced in Android API 26. Collect currently has a minimum SDK of 16.

I worry about this class of issues where we use some method in JavaRosa that isn't supported in Collect. Is there a systematic way of catching these?

I do too. I can't find any automated way to check for it, unfortunately. @ggalmazor, maybe? Or maybe we need to build with Java 7?

Ugh! Sorry I didn't realize that before approving the PR :/

I don't know any way to automatize these checks, but I'm studying it.

OK, so, this is what I've tried:

  • Create an empty Android project with support for API level 16.
  • Tune it to make Gradle build it using Java language level of 8 (support diamond operator and better type inference) to match JavaRosa's requirements
  • Add JR's dependencies to the Android app's gradle conf file
  • Copy JR's code to the Android app's sourceset
  • Run ./gradlew clean check

This will detect anything not supported by the minimum API level we set on the Android project.

In fact, it detects an illegal try/catch in FormDef that we didn't know about before this:

image

What I'd like to do now is to add the blank Android project inside a ZIP file that a Gradle task could unzip and prepare with JR's source code to be able to add a step in CircleCI that prevents build to use unsupported language features.

This would make all the checks we need to prevent this problem once and for all.

OK, I've created a PR that does all of this. It's currently failing the build due to the compat error mentioned before: #505

image

The lint report (HTML) is stored as an artifact that can be browsed(example)