Build android

From SoftwareGuy
Jump to navigation Jump to search

To build Android, follow these three steps from the Android root.

1. export ARCH=arm

2. export CROSS_COMPILE=~/projects/Android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-

3. source build/envsetup.sh

4. lunch pb200i-eng

4a. sudo apt-get install u-boot-tools uuid uuid-dev liblzo2-2 liblzo2-dev g++ gperf libswitch-perl libxml2-utils

4b. cd bootable/bootloader/uboot-imx

4c. export ARCH=arm

4d.

       export CROSS_COMPILE=~/projects/Android/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-
       export CROSS_COMPILE=~/projects/Android5.1/Prebuilt_Lolli/gcc/linux-x86/arm/arm-eabi-4.6/bin/arm-eabi-

4e. make pb200i_android_config or make pb200iandroid_defconfig (5.1) or make hbi-120android_defconfig

4f. make

4g. cd ../../..

4h. to build on 16.04

sudo add-apt-repository ppa:openjdk-r/ppa  
sudo apt-get update   
sudo apt-get install openjdk-7-jdk  
sudo apt-get install openjdk-7-jre

4i. make bootimage

5. make –j12

If this fails due to OpenJDK, try this: sudo update-alternatives --config java

Now make sdcard

6. sudo ./device/fsl/common/tools/fsl-sdcard-partition.sh /dev/sdb

7. ./tosd

Now if you want a ota distribution...

1. make -j8 dist

1b. New command "make otapackage"!!! Try this if the previous command generates an image that boots only once.

2. adb push out/dist/pb200i-ota....zip /sdcard

3. adb shell

3a. busybox cp /sdcard/pb200i-ota....zip /cache/update.zip

3b. echo "--update_package=/cache/update.zip" > /cache/recovery/command

3c. reboot recovery

Now to build the new hbi kernel stuff...

sudo apt-get install lzop

 cd Uboot_Lolli/
 make hbi-120android_defconfig
 export ARCH=arm
 export CROSS_COMPILE=~/projects/Android5.1/Prebuilt_Lolli/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi-
 make u-boot.imx
 cd Kernel_Lolli/
 make hbi-120_android_defconfig
 make zImage imx6q-hbi-120.dtb  -j 8
 sudo dd if=u-boot.imx of=/dev/sdX bs=1024 seek=1

Now to build the full Android/kernel distribution...

First replace ld in the prebuilts

 cd prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/x86_64-linux/bin/
 ln -s /usr/bin/ld.gold ld
 cd prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.8/x86_64-linux/bin/
 ln -s /usr/bin/ld.gold ld

sudo apt-get install bison uuid uuid-dev zliblg-dev liblz-dev curl m4 android-tools-fsutils

 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
 export ARCH=arm
 export CROSS_COMPILE=~/projects/Android5.1/Prebuilt_Lolli/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi- 
 make -j8 BUILD_TARGET_DEVICE=sd > make.log 2>&1
   or
 make -j8 BUILD_TARGET_DEVICE=sd

To reset the workspace:

 git fetch --all
 git reset --hard origin/l5.1.1_2.1.0-ga-hbi-120
 cp arch/arm/boot/zImage /media/<user>/<partname>/ && cp arch/arm/boot/dts/imx6q-hbi-120.dtb /media/<user>/<partname>/

To build on host 18.04 systems:

export LC_ALL=C 

see aosp_issue

Adding apps to the build[edit | edit source]

http://stackoverflow.com/questions/10579827/add-apk-files-in-aosp

https://wiki.cyanogenmod.org/w/Doc:_adding_your_own_app

http://grokbase.com/t/gg/android-building/12bt8dggh7/how-to-add-my-prebuilt-apk-to-sys-img

Current build steps[edit | edit source]

../androidSetup
source build/envsetup.sh 
lunch hbi120-eng
make -j 6 dist
../ota <filename>
cd out/target/product/hbi120
sudo ../../../../device/fsl/common/tools/fsl-sdcard-partition_1604.sh -f imx6q /dev/sdc