My Build Experience ---- Do's and Don'ts
Caveat: Just documenting my "do's and don'ts" experiences, while I try and learn how to build LineageOS for the d2vzw.
Just to document how much research I've been doing leading to where I am today, here are my notes. Maybe someone else trying to learn will find something useful.
Websites with valuable information that helped (thanks to all the people involved with those pages)
https://wiki.lineageos.org/devices/d2vzw/build
https://xdaforums.com/chef-central/android/how-to-build-lineageos-14-1-t3551484
https://gist.github.com/fourkbomb/ce92262fc633a9a001e19095c0e9d734
https://download.lineageos.org/shamu
https://www.reddit.com/r/LineageOS/...am_i_building_it_the_efficient_way_are_there/
https://www.reddit.com/r/LineageOS/...am_i_building_it_the_efficient_way_are_there/
https://github.com/TheMuppets/proprietary_vendor_samsung/tree/lineage-15.1/d2-common/proprietary/bin
IMPORTANT - when you open a command line window, do ALL of these commands within that SAME window... each window is isolated WRT setting variables
First part is to setup build environment and download the android repository (repo)
I followed this guide to accomplish this step
https://xdaforums.com/chef-central/android/how-to-build-lineageos-14-1-t3551484
I then deviated from the build procedures in the guide above. Those procedures let you create an unsigned build, which, while it will "work", isn't be best solution. I followed the instructions below to setup the signing infrastructure, and then sign everything after the building process is over.
Generating the keys that will be necessary to sign your builds
Note: You only need to run this ONCE.
BACKUP these CERTIFICATES!!!!
If you ever loose them and need to rerun these, you’ll need to migrate between builds, which means WIPING DATA (aka Factory Reset)
Make sure you are in the root of your Android tree (~/android/system)
These parameters will be used to define a system variable that will be used to create the signing certificates.
/C=<your country>
/ST=<your state>
/L=<your city>
/emailAddress=<your email address>
Run the following commands <edit the parameters listed above, within the 'subject' variable below. My specific information is used below.
subject='/C=US/ST=Florida/L=Orlando/O=Android/OU=Android/CN=Android/emailAddress=android@myisp.com'
mkdir ~/.android-certs
for x in releasekey platform shared media; do ./development/tools/make_key ~/.android-certs/$x "$subject"; done
You will be asked to create a PASSWORD for the certificates.
The password can be left blank.
If you do use a password, when flashing later, you will get a ZIP Verification error.
To get around the error, disable ZIP Verification checking in TWRP.
Signing will required additional certificates {cyngn-app,cyngn-priv-app,testkey}.{pk8,x509.pem}
These certificates can be created by using symbolic links to the releasekey cert
Put these in the same folder you generated media,platform,releasekey,shared.
It'll look like this when you are done:
lrwxrwxrwx 14 cyngn-app.pk8 -> releasekey.pk8
lrwxrwxrwx 19 cyngn-app.x509.pem -> releasekey.x509.pem
lrwxrwxrwx 14 cyngn-priv-app.pk8 -> releasekey.pk8
lrwxrwxrwx 19 cyngn-priv-app.x509.pem -> releasekey.x509.pem
-rw-r--r-- 1217 media.pk8
-rw-r--r-- 1115 media.x509.pem
-rw-r--r-- 1218 platform.pk8
-rw-r--r-- 1115 platform.x509.pem
-rw-r--r-- 1216 releasekey.pk8
-rw-r--r-- 1115 releasekey.x509.pem
-rw-r--r-- 1217 shared.pk8
-rw-r--r-- 1115 shared.x509.pem
lrwxrwxrwx 14 testkey.pk8 -> releasekey.pk8
lrwxrwxrwx 19 testkey.x509.pem -> releasekey.x509.pem
Create the symbolic links by running:
Hint: copy and paste the entire script onto the command line and press enter.
# symlink certs
for c in cyngn{-priv,}-app testkey; do
for e in pk8 x509.pem; do
ln -s releasekey.$e $c.$e;
done;
done
Six new certificates should show up. You are done with this step.
Now it's time to build lineageos. Run the following commands:
Note that <codename> is the name of your specific phone. In this case it is the Verizon version of the Samsung Galaxy SIII --> d2vzw
cd ~/android/system
make clean
rm /home/bakermj/android/system/out/dist/*target_files*
repo sync
source build/envsetup.sh
breakfast d2vzw
export USE_CCACHE=1
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
mka target-files-package dist
Sit back and wait for a while - it may take a while depending on your computer’s specs.
If you see a LOT of WARNING messages, don't worry, that is normal.
After it’s finished, you just need to sign all the APKs:
croot
TARGET_FILES_SIGNED=lineage-$(get_build_var LINEAGE_VERSION)-signed-target_files.zip
./build/tools/releasetools/sign_target_files_apks -o -d ~/.android-certs ~/android/system/out/dist/*-target_files-*.zip $TARGET_FILES_SIGNED
The file 'lineage-<LINEAGE_VERSION>-signed-target_files.zip" will be in ~/android/system
Generating the install package
Now, to generate the installable zip, run:
OTA_PACKAGE=lineage-$(get_build_var LINEAGE_VERSION)-install.zip
./build/tools/releasetools/ota_from_target_files -k ~/.android-certs/releasekey --block --backup=true $TARGET_FILES_SIGNED $OTA_PACKAGE
The build is located in ~/android/system
This build requires a factory reset, which means you will then need to install GAPPS afterward.
If you did a FULL wipe (including System), then you will loose root.
If that happens you will need to flash addonsu-14.1-arm-signed.zip which is located here
https://download.lineageos.org/extras
__________________________________________________________________________
Other method for signing and building, BUT there are ISSUES with this process at the moment, so DO NOT USE, as it DOES NOT WORK
Create certificates as above.
Create symbolic link to certs.
goto /home/bakermj/android/system/device/samsung/d2vzw
edit full_d2vzw.mk
add to the end of the script
PRODUCT_DEFAULT_DEV_CERTIFICATE := /home/bakermj/.android-certs/releasekey
save the file
now build using:
cd ~/android/system
repo sync
source build/envsetup.sh
breakfast d2vzw
export USE_CCACHE=1
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx4096m"
croot
brunch d2vzw
the build process will sign the files as it is being built...
nothing else to do afterwards
the build will be located in /home/bakermj/android/system/out/target/product/d2vzw