samedi 24 janvier 2015

[GUIDE] Building independent system apps from Lollipop source for OnePlusOne topic






#This is a simple guide to download, modify and build system apps on CM12.0 based Blisspop fork for bacon device (OnePlusOne)
#Last edited: 2015-01-23

Was trying to modify some system app functionalities and it turns out the methods of decompiling - modify smali - recompiling did not work well. So had to try building from source. After three days of trials and errors, I succeeded in building the desired system apps without having to compile the entire rom. There is a similar guide on XDA-University, and also the same guide I went to for answers first. But that is largely out-dated, so I'm not going to cover it here. Most of the readings I did was on XDA and CM Wiki, so I thought I'd post my findings here as a way of appreciation, and hopefully will reduce the amount of research for folks with similar needs.

For people who want to build entire Lollipop rom from source, GRMrGecko wrote an excellent guide here:
http://forum.xda-developers.com/onep...s-one-t2947949

And to make things easier, I'm going to use bits from GRMrGeCko's guide so readers of this thread won't need to jump to other links to figure out exactly how.

So, how do you build system apps without having to build the entire rom?

1. Establishing android develop environment. Install 64bit version of Unbutu, I used the iso with 'AMD64" in it, and the version is 14.04. Make sure you allocate more than 60G for source code and building - those tend to take significant storage. In my case, I was using an Asus 1215T laptop, with an ancient single core AMD CPU, and 2G memory, plus 500G hard disk.

Once installed, ctrl+alt+T to open the terminal and Install the following items via apt-get:

sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-6-jdk openjdk-6-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

As per the instructions on the wiki for building CM, if you use a 32bit system, do not install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev.

#Install the latest version of Java's development kit using the following:

sudo apt-get install openjdk-7-jdk

#Install the Android Development Kit using the following.

sudo apt-get install android androidsdk-uiautomatorviewer android-copyright android-src-vendor android-emulator android-tools-adb android-headers android-tools-adbd androidsdk-ddms android-tools-fastboot androidsdk-hierarchyviewer android-tools-fsutils androidsdk-traceview

#Then, install repo:
mkdir -p ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

reboot your system or use the following in terminal to load the .profile file again:
. ~/.profile

2. make a folder (any name would do) to store the code. Go into the folder (i.e. cd /home/uersername/BlissPop) and get the source code:(you'll only get the latest main branch this way - I suppose. All commands in terminal console have assumed that the source code root folder is current folder)
repo init -u https://github.com/TeamBliss-LP/android.git -b lp5.0

repo sync

#Note: this will download the specified branch lp5.0 (lollipop 5.0 of Blisspop) onto your local drive. The source as of Jan. 23, 2015 is 10+GB, so be patient and try different vpn connections to get the most desirable speed. It took me overnight to download the source code.

3. Build

#Note: This is the tricky part. The existing documentation of Blisspop or other similar open source project does not explicitly explain whether you need to sync full project tree to be able to just compile specific modules (i.e. Source Folder/packages/apps/Email). After experimentation, the answer is a most definite yes. The reason is that system apps usually have many framework-level dependencies, which means downloading the entire source code is the safest way to ensure a successful build. However, you don't need to build the entire rom, or firmware, which takes hours on a single core Asus 1215T.

#To compile specific system apps. After repo sync

a) initiate build environment

. build/envsetup.sh
breakfast bacon

#Note, if you encounter device tree related errors in build steps below, try repeating the above two steps, and run repo sync after breakfast bacon. This, according to CM documentation, will download the specific device tree into the local repository.

b) build the specific app and all its dependencies

#go into the app folder (i.e. cd /home/username/Blisspop/packages/apps/Email)

mma

# Wait until the compilation is over, this on a single core AMD Asus 1215T takes about 2-3 minutes.

#The compiled and signed app should be in out/product/bacon/Email folder. Ready to be copied and flashed using root explorer in your OnePlus's system/app folder.

#When rebuild an app after mma has been executed at least once, no need to build all dependencies, hence:

#go into the app folder (i.e. cd /home/username/Blisspop/packages/apps/Email)
mm






Aucun commentaire:

Enregistrer un commentaire