Today I started getting strange errors whenever I added a dependency to our Android app. The dependencies installed without issue and the project would even build. However attempting to run the project failed with a
The problem is that Dalvik (and maybe Java?) has a limited number (65,536!) of addresses for references. The number of available addresses is so large that this normally isn't a problem. In our case we hit that limit just by adding one extra dependency! (Note that this isn't meant to be a poor reflection on the dependency, which is why I'm not calling it out by name. We where already really close, and it just pushed us over the edge.)
The fix is pretty simple, at least for the short term: just enable
build.gradle. I have no idea what our new reference limit is now, and I definitely don't want to run into it. In the long term, I would love to restructure and simplify/reduce the codebase, but that's not really an option for me at this point.