Sunday, September 9, 2012

Include external jar in Blackberry


1. Obfuscate the library jar using proguard. Somehow blackberry do not allow deep obfuscation (Crap). E.g.,

**********************************************************************************
-libraryjars WTK2.5.2\lib\midpapi21.jar;WTK2.5.2\lib\cldcapi11.jar
-forceprocessing
-useuniqueclassmembernames

-keepparameternames
-renamesourcefileattribute SourceFile
-keepattributes Exceptions,InnerClasses,Signature,Deprecated, SourceFile,LineNumberTable,EnclosingMethod

# Keep - Library. Keep all public and protected classes, fields, and methods.

-keep public class com.* { public protected *; }
**********************************************************************************

2. Preverify the jar located in your blackberry simulator plugin.

**********************************************************************************
SET RIM_EMUL_DIR=eclipse\plugins\net.rim.ejde.componentpack4.5.0_4.5.0.30\components
%RIM_EMUL_DIR%\bin\preverify  -classpath %RIM_EMUL_DIR%\lib\net_rim_api.jar %OUTJAR% 

**********************************************************************************

3. Add the preverified jar(located in the output folder) to your blackberry project.