2014-11-20

Enable Sinhala fonts rendering in Nexus 7 Android 5.0 Lollipop

I think you already know that Nexus 7 (2012) Android 5.0 factory image is out. Anyone can download it from here and isntall it.

If you have successfully flashed it to your Nexus and if you are not seeing "Sinhala" characters properly you can enable it from the following method.

If you haven't already root the new ROM
Goto CF-Auto-Root beta download site

Download correct boot image. You will find a zip file there.

Turn off your device. Goto boot loader by holding volume down + power
Connect the USB cable.

Unzip it. Run
For Linux : root-linux.sh
For Mac : root-mac.sh
For Windows root-windows.bat

Your device will restart several times and install SuerpSU (Root utility) after final successful boot.

Now your device is rooted.

Download Sinhala fonts from Google noto fonts
You'll get a zip file which has two .ttf Sinhala fonts.
(NotoSansSInhala-Regular.ttf and NotoSansSInhala-Bold.ttf)

In order to add Sinhala font files you'll need a file browser which has root access capability.

I used ES file explorer. Find it on Google Play
In ES file explorer you have to open left drawer and enable Root Explorer feature to access system files.

Copy two .ttf files which you downloaded earlier and copy them to the device
/system/fonts/
folder

Now reboot the devices and you'll see proper Sinhala character rendering.

2014-03-15

[Android] Find unused resources in a project

Most of the time we may need to delete unnecessary images or other resource files before we deploy our project. Searching them one by one and deleting them will be a pain.So here is a simple procedure to find them automatically using Android Lint and remove them by a shell script.

1. Find resources

You can run a Lint check from the IDE you are using. But if your project has a pile of lint warnings it may seem impossible to find the unused resources. Therefore we need to run it using console.

First you have to go to the android sdk tools directory using  :

cd “path to android sdk tools directory”

Ex:

Then check whether the lint is working properly by running this command:



If you experience an exception similar to “exception in thread "main" java.lang.NoClassDefFoundError: lombok/ast/AstVisitor”
go to  \android-sdk-windows\tools\lib and rename lombok-ast-0.2.2.jar (or with a different version) to new file name “lombok-ast.jar”
Try again and it should show the version of Lint

Now check for unused resources by

lint --check UnusedResources  --fullpath “path to project folder (where AndroidManifest.xml is)” > resources.txt

Ex:

It will take some time depending on the number of project files. After that a file named “resources.txt” will generate in the console working directory. (If you run Lint from \android-sdk-windows\tools , the file will be located there)

2. Remove unused resources

Open that “resources.txt” file and go through the unused file list and delete resource files one by one. If you feel lazy for that execute following java file/ jar file and generate batch/shell and run it. (I did that to automate process)

To execute jar file run this on console
OS_ID : 0=windows(generate unused.bat) and 1=linux(generate unused.sh)
lint_check_resource_output_file : resources.txt file

Ex:
java –jar lintreader.jar 0 resources.txt

This will generate unused.bat or unused.sh files depending on the OS_ID you provide.

Execute this generated file in the console and unused android project resources will be deleted automatically.

To execute batch file in windows simply type in command prompt
To execute shell script in linux simply type in console