Skip to content

Move code causing verify error into separate helper class

Fixes #748 (closed).

I'm not 100% sure on how the @TargetApi and VerifyError work together. However it is something along the lines of:

  • Class loader needs CleanCacheService.
  • At this point, it loads the bytecode for that class and verifies that it all makes sense.
  • The bytecode within the method targeted at API 21 is not understood by earlier APIs, because the entire Os class was introduced in 21.
  • By putting it into a different class, that class is only loaded at runtime on devices with API of 21 or higher.

Previously, @TargetApi + the relevant guard condition to check the build version at runtime suffices to prevent this. However it seems that if the entire class does not even exist on earlier APIs, then it is no longer good enough.

Merge request reports