Wednesday 17 December 2014

Implement Arxan GaurdIt protection for Android application having library project

If you are stuck with Arxan protection for an Android application having library project please see few steps below

1. Edit Gaurdspec.gsml like ..

<target>        <pair>            <input>bin/classes</input>            <output>bin/guardit4j/protectedclasses</output>        </pair>        <pair>            <input>../library/bin/classes.jar</input>            <output>bin/guardit4j/protectedlibs/classes.jar</output>        </pair></target>

Add pairs for all the library project along with all the jars from lib folder. If you have 3 library project and each of them are using another 3rdparty jars resides in the respective libs folder add that as a pair also.

2. Add the lines below in gaurd4jrules.xml to marge all the library project into a single obfuscated.jar

<!-- Merge the protected app, the protected Container and any other library jars into 1 file -->   <jar destfile="${guardit4j.dir}/obfuscated.jar">      <fileset dir="${guardit4j.protected.dir}"/>      <zipfileset includes="**/*" src="${guardit4j.dir}/protectedlibs/classes.jar"/>
  </jar>   <!-- Clear list of library jars to be converted to Dalvik - all code must be in obfuscated.jar -->        <path id="out.dex.jar.input.ref"/>

3. If you are using Gson library then modify gaurd4j.bat and append "-DKeepSignatures" with the java command.

For further help please fill free to contact me.


ant: warning: unmappable character for encoding UTF8

During Jenkins implementation I have to configure my Android application using Ant build, but I have got warning like "ant: warning: unmappable character for encoding UTF8". Which is anyway build the entire application and create the APK file, but when I run the application it displays "?" instead of "€". Then I have been searching though Google, got many answers but none of them solve my problem. Then I figured out it is the Eclipse setting I have overlooked :-).

The code snippet I am getting this issue is given below

String EURO_SYMBOL = "€";
So what happened, when I have copy pasted the  "€" sign then my Eclipse project setup for  "Text File Encoding" was "Cp1252". So "€" got converted to "Cp1252" automatically.  But default encoding for Ant was "UTF-8", so during compilation Ant try to convert all the files to "UTF-8" , which caused a junk character like "?" has been introduced.

To overcome this first I have to change my "Text File Encoding" to "UTF-8" and then I copy pasted "€" again to the line above and it solve my purpose.

Please add your comments if you still getting the warning.