Android java.lang.VerifyError and Boilerplate code

Posted by in Software

TL;DR: Change the java version compatibility in your gradle file (see below) or remove Hugo references from your e.g. “debug” code in Velcro.

The other day I discovered a bunch of template-based application generators for android. While they are very interesting and apply some of the best practices, they come with a footnote:

Use it at your own risk, particularly if you’re not that familiar with the dependency libraries.

So, I’ve started using Velcro as a starting point and was pleasantly surprised of things like Dagger and Hugo and the reduction of handmade code. Until it stopped working that is. Initially, I’d get “normal” errors like NPEs or “networking on ui thread” which were due to my lack of understanding of the framework.

Once I fixed them, it worked for a while and then it stopped again with java.lang.VerifyError exception and I could not figure out what I did wrong…


After looking on the internet for this exception, the most interesting answer was this. My translation is that the class generating the VerifyError is somewhat broken. I’ve looked into my code, the generated code and could not come up with a decent answer (or fix for that matter). In the end, I started digging what the error actually means.

When the application starts, classes are verified for integrity before loading. VerifyError occurs when this sort of verification fails. In my case, the error came up from an injection by Hugo. There’s an ongoing (at the tiem of writing) bug here on this issue.


My solution was to remove Hugo altogether from the “debug” part of the code (where this error actually occurred). One of the other proposed solutions is to change the JavaVersion from JavaVersion.VERSION_1_7 to .JavaVersionVERSION_1_6 in your compile options in your gradle build file:

A little experiment: If you find this post and ad below useful, please check the ad out :-)