When using Proguard I was getting a VerifyError on SDK 3 when trying to 
access the Version.SDK_INT field.

With proguard disabled, everything worked fine because I was using the 
standard approach of using a wrapper class to prevent VerifyErrors:

public static int getSdkInt() {
int sdkInt = getSdkIntSafely(); if (sdkInt < 4) { return sdkInt; } else { 
return VersionSdkIntWrapperForDonut.getValue(); } } private static int 
getSdkIntSafely() { try { return Integer.parseInt(VERSION.SDK); } catch 
(Throwable t) { return -1; } }  
private static class VersionSdkIntWrapperForDonut {
private static int getValue() {
return VERSION.SDK_INT;
}
}
However, it appears that (using the default Android Proguard config), the 
wrapper class was being "optimized" in such a way that this technique no 
longer worked.

My current workaround is to specify -dontoptimize which works fine.

Is there a more specific flag to use?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to