Tuesday, May 28, 2013

VerifyError : Verifier rejected class errors in Android + ProGuard


Today, all of the sudden we started getting


VFY: Ljava/lang/Object; is not instance of Ljava/lang/String;
VFY: bad arg 0 (into Ljava/lang/String;)
VFY:  rejecting call to Ljava/lang/String;.format (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
VFY:  rejecting opcode 0x71 at 0x01e4


It is kind of frustrating when you see errors like this in LogCat with out pin-pointing where is the actual problem is. Once the code gets obfuscated, it is no longer the code we used to work on.  First enable the mapping in ProGuard . ProGuard  creates a nice map on which methods and properties get renamed to what, it is easy to track down which method is causing the problem.

In my case, I found out which function is causing the problem but that did not mean there is a problem with the code, because real code worked fine and after obfuscating only started having above issue.

When i Googled bit more I came across this post in StackOverflow

http://stackoverflow.com/questions/4980047/proguard-error-with-method-signatures

he suggests to move to the latest version of the ProGuard. I was on ProGuard 4.5 and when changed it to use ProGuard 4.9 it worked !

From what I understood, problem is during the run-time is looking for a class that is no longer there and it's causing this exception. During the obfuscating process it did something to String.Format and whole thing fell apart .

No comments:

Post a Comment