Sunday, February 17, 2013

Setting up Apktool

In case you did not have prior knowledge of how to setup apktool on a Linux  based machaine here is how. There are many tutorials dealing with how to set up the parts, individually, some good some not so much, but I will consolidate them here. Apktool is very useful for modifying android applications especially for theming, which I covered previously. I will guide you through the installation of JDK 6  and apktool so it is in your file path, ready to use.  To get started you will need the following:


  1. A linux distro, I am using Ubuntu 12.04, but the choice is yours although I would recommend a Debian based one, such as Ubuntu, Xubuntu, or Mint.
  2. Java JDK 6 (not open JDK or JDK7, the current version is 1.6.0_39, so the installation commands will be based on this. 
  3. Apktool.jar v1.52 along with the aapt and apktool script.


The first step is to download the files:
  • Jdk 6 found here the one you will need is jdk-6u39-linux-x64.bin , first accept the agreement and then you can download.  
  • Next you will need apktool, the thread can be found here, you need to download both the jar and aapt. 


To install JDK 6



First we will install the jdk 6 here is a good tutorial if you need it also:
  • First open a terminal and change directories to your wherever you downloaded jdk-6u39-linux-x64.bin.  For me the command is:
cd Downloads
  • Next you need to give the .bin file permissions, the command is:
chmod a+x jdk-6u39-linux-x64.bin 
  • Now we extract it with this command:
./jdk-6u39-linux-x64.bin 
  • Make a folder called jvm in /usr/lib/ you will have to use root (you have to type your password) so the command is:
sudo mkdir /usr/lib/jvm
  • Move your entire extracted folder to /usr/lib/jvm, assuming you are still in the folder of the extracted jdk file the command is:
sudo mv jdk1.6.0_39 /usr/lib/jvm
  • Finally to actually switch to jdk 39 you need to do the following:
wget http://webupd8.googlecode.com/files/update-java-0.5b
  • Then give that file permissions:
chmod +x update-java-0.5b
  • Finally to run the program:
sudo ./update-java-0.5b
  • Select jdk1.6.0_39 and click OK to test if everything worked type this 
java -version

javac-version

  • You should something similar (mine is actually 1.6.0_38, ), if not re-read or post in the comments:





To install apktool 


  • If you want further reading go here
  • First you will need to navigate to the location to where you downloaded apktool-install-linux-r05-ibot.tar.bz2 and apktool1.5.2.tar.bz2
  • Right click  and hit extract, then move the contents of the folder to the root of the Downloads folder, it should now look like this:

  •  For the next step you need to know the name of your home directory (often your username), we will use this to change the owner of the three files. Commands are as follows:

chown -R theapant:theapant '/home/theapant/Downloads/apktool.jar'

chown -R theapant:theapant '/home/theapant/Downloads/apktool'

chown -R theapant:theapant '/home/theapant/Downloads/aapt'



**note change theapant with whatever your username is, each time it appears**


  • Now we need to change the permissions (make executable)


sudo chmod +x '/home/theapant/Downloads/apktool.jar'

sudo chmod +x '/home/theapant/Downloads/apktool'

sudo chmod +x '/home/theapant/Downloads/aapt'

  • Finally just move the three files to /usr/local/bin, if you are still in the Downloads folder the commands are:



sudo mv apktool.jar /usr/local/bin

sudo mv apktool /usr/local/bin

sudo mv aapt /usr/local/bin



  • To test if everything worked just type apktool and if something like this comes up, you know it worked:


If you have gotten this far, then my other tutorial on theming by decompiling apks, will probably be benificial in learning some apktool commands/usage. 










Saturday, February 16, 2013

Theming the Clock

This tutorial will be done using Ubuntu 12.04, although all tools are available for Windows and OSX; however the commands will differ (OSX might be the same since it is also UNIX based).  You could easily use UOT Kitchen if you want an easy theme.  However if you want more options and to actually know what is happening, use this guide.

***disclaimer, make a backup of your ROM, if this is done wrong you may have to restore***

To begin theming, you will need several things:


  1. A rooted phone, I will be using the Samsung Galaxy Exhibit, running CM7, courtesy of Tim1928
  2. A launcher of choice I will be using ADW
  3. Photo editing software (Gimp, Photoshop, paint, or some equivalent)
  4. Apktool, set up with apktool in your file path (Here is a tutorial) 
  5. Preferably adb set up; however this is not necessary, you could use ES file explorer
  6. Archive manager such as roller (comes with linux) or 7zip
  7. Text editor (gedit, notepad ++, etc...)
  8. Prior knowledge of how to use the above tools (Google, xda, and rootzwiki are all helpful)

We will only make one modification to the status bar.   After learning the process, you can modify anything you want.  This will make the time in the status bar pink or whatever color you like.


What it looks like now

The first step is to get SystemUI.apk (located in system/app/) and framework-res.apk (located in system/framework) and put them in a folder.  

ADB commands for linux are as follows:



open terminal 

cd android/sdk/platform-tools

./adb pull /system/framework/framework-res.apk /home/theapant/theme

./adb pull /system/app/SystemUI.apk /home/theapant/theme



**replace /home/theapant/theme with the path to your theme folder**



The second step is to install the framework-res.apk, commands for linux are as follows:

open terminal

cd theme

apktool if framework-res.apk 



The third step is to decompile SystemUI.apk and framework-res.apk, commands for linux are as follows:

open terminal

cd theme

apktool d SystemUI.apk 

apktool d framework-res.apk

The fourth step is to modify all the files you want.  For just the clock you only need modify this in SystemUI/res/layout/status_bar.xml.  First find the line 

<com.android.systemui.statusbar.Clock and add this  before the />

android:textColor="#fffb07e7" 

**note, change the 6 characters after #ff to whatever color value you want. (here is a good website to find the value http://html-color-codes.info/)**

Save the file and make a new folder inside theme.


Now it's time to recompile,commands for linux are as follows:

open terminal

cd theme


apktool b SystemUI new/new.apk






Now it's time to zipalign the app, commands for linux are as follows:


open terminal

cd theme/new


zipalign -v 4 new.apk SystemUI.apk







Finally to remove the old SystemUI.apk and replace it with this one, use the following commands:


open terminal

cd android/sdk/platform-tools

./adb shell

mount -oremount,rw /dev/block/mtdblock3 /system

rm /system/app/SystemUI.apk

close terminal

open terminal

cd android/sdk/platform-tools

./adb push /home/theapant/theme/new/SystemUI.apk /system/app

reboot




If that doesn't work for you and the status bar is gone, with an archive manager open both of the apks and drag and drop in status_bar.xml into SystemUI.apk/res/layout of the original apk and repeat the previous steps to remove the old apk and push the new one.



There you have it! If you have issues, post in the comments and myself or someone can help resolve it.