Thursday, May 30, 2013

Android 4.2 adb offline issue in Nexus 4 and Samsung S4

Today I plugged in Samsung S4 and it did not show up in the adb. So I tried my Nexus 4 and it did not show up either. When I tried S2 it worked. So I thought it's must be something in Android 4.

So I updated the SDK via SDK Manager.exe and still did not solve this problem. When I looked at the adb Android documentation it says

When you connect a device running Android 4.2.2 or higher to your computer, the system shows a dialog asking whether to accept an RSA key that allows debugging through this computer. This security mechanism protects user devices because it ensures that USB debugging and other adb commands cannot be executed unless you're able to unlock the device and acknowledge the dialog. This requires that you have adb version 1.0.31 (available with SDK Platform-tools r16.0.1 and higher) in order to debug on a device running Android 4.2.2 or higher.

When i checked my adb version after updating, it was still 1.0.29, strange somehow it did not download 1.0.31. So I downloaded the latest tool set from and copied the platform-tools folder to my existing folder and I did "adb version" and got 1.0.31. Now when I tried "adb devices" still not getting the device. Finally  I unplugged the USB cable and re-connected and It worked.

Make sure to check "trust this computer" so it will save the settings.

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

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 .