Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<project name="custom_rules">
<!--
Suppress "Warning: can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])".
Per http://www.dancartoon.com/2012/01/14/fixing-proguard-warning-cant-write-resource-meta-infmanifest-mf/
Target "-obfuscate" copied from ${sdk.dir}/tools/ant/build.xml v21.
-->
<target name="-obfuscate">
<if condition="${proguard.enabled}">
<then>
@dcartoon
dcartoon / ProGuard_4.9_iae.java
Created February 12, 2013 00:11
Code snippet that causes an IllegalArgumentException in ProGuard 4.9 beta 2
@Override
public Bitmap loadBitmapFromFile(INetworkImageType imageType, String fileName, Bitmap reusableBitmap) {
Bitmap bitmap = null;
File bitmapFile = null;
try {
bitmapFile = new File(fileName);
if (bitmapFile.exists() && bitmapFile.isFile()) {
...
@dcartoon
dcartoon / ProGuard_4.7_npe.java
Last active December 12, 2015 10:19
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;
}
...
@dcartoon
dcartoon / gist:1610031
Created January 14, 2012 02:45
ProGuard - Filtering Manifest Files
-injars in1.jar
-injars in2.jar(!META-INF/MANIFEST.MF)
-injars in3.jar(!META-INF/MANIFEST.MF)
@dcartoon
dcartoon / gist:1609994
Created January 14, 2012 02:31
Standard Android ProGuard build.xml Config
<!-- Build a path object with all the jar files that must be obfuscated.
This include the project compiled source code and any 3rd party jar
files. -->
<path id="project.jars.ref">
<pathelement location="${preobfuscate.jar.file}" />
<path refid="jar.libs.ref" />
</path>
<!-- Set the project jar files Path object into a single property. It'll be
all the jar files separated by a platform path-separator.
Each path must be quoted if it contains spaces.
@dcartoon
dcartoon / gist:1609983
Created January 14, 2012 02:29
Fixing Android ProGuard Duplicate META-INF/MANIFEST warnings
<!-- Set the project jar files Path object into a single property. It'll be
all the jar files separated by a platform path-separator.
Each path must be quoted if it contains spaces.
-->
<pathconvert property="project.jars" refid="jar.libs.ref" pathsep=" ">
<firstmatchmapper>
<regexpmapper from='^([^ ]*)( .*)$$' to='-injars "\1\2"(!META-INF/MANIFEST.MF)'/>
<regexpmapper from='(.*)' to='-injars \1(!META-INF/MANIFEST.MF)'/>
</firstmatchmapper>
</pathconvert>
@dcartoon
dcartoon / returns.rb
Created July 17, 2011 03:06
Implicit vs. Explicit Returns
# Simple demonstration of an 'implicit' return
def implicitReturn()
"implicit return\n"
end
# Simple demonstration of an 'explicit' return. Using an explicit return,
# even within a block, will exit the function.
def explicitReturn()
examples = ["pangolin", "cat", "macgyver"]