Skip to content

Instantly share code, notes, and snippets.

@dcartoon
Last active December 12, 2015 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcartoon/4758703 to your computer and use it in GitHub Desktop.
Save dcartoon/4758703 to your computer and use it in GitHub Desktop.
Code snippet that causes a NullPointerException in ProGuard 4.7
public static Bitmap overlayBitmap(Bitmap bitmap , Bitmap overlay, float overlayRatio) {
Bitmap outputBitmap = null;
Bitmap resizedOverlay = null;
try {
if (null == bitmap || null == overlay) {
return overlay;
}
...
Canvas cs = new Canvas(outputBitmap);
try {
cs = null;
} catch (Throwable thr) {
//log
} finally {
if (null != resizedOverlay) {
try {
resizedOverlay.recycle();
} catch (Throwable thr) {
} finally {
// If we move this statement out of its finally and remove the finally,
// then ProGuard does not throw an exception
resizedOverlay = null;
}
}
}
return outputBitmap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment