Video Tutorial for Building Android: Advanced Topics

twrp
Praise God! Another video series featuring more advanced material!
Previously, I had created a video tutorial and guide for how to compile Android, from Lollipop through Marshmallow, Nougat, and Oreo. If you need help learning the basics or intermediate material, please see my other video tutorial thread on XDA, Or here on my website through the navigation bar at the top.

Who is this video series for?
Well, this video tutorial is a guide built primarily for the intermediate Android developer. This is written for those who already know how to compile custom roms for a phone that they own using device trees and vendor files that are already available. Things like using git, GitHub, GitLab, ADB, fastboot, and repo sync should already be something familiar to them.

That said, I believe that an intermediate developer will find this set of videos to be most helpful. The goal of this video series is to push the intermediate developer up to a rudimentary advanced level.

Advanced developer?
An advanced rom/kernel developer will probably far exceed my feeble abilities, and will not likely find much useful information here. Perhaps if you are an advanced developer, you would consider making another tutorial or adding to this advanced video series! (See further posts for recommendations on contributing videos.) Please! I’d really like to add links to your YouTube channel, or your git repository full of advanced topics for developers! Help up the quality of devices and builds of Android by showing others what you know how to do best!

Why did you put this together?
Well, after releasing the previous tutorial, explaining to beginners how to use things like git, repo sync, compile roms, and do small kernel modification, it was brought to my attention that a more advanced course was needed for intermediate users who already know how to build roms, but may (like myself) struggle with more complicated tasks. I don’t know how to do everything, and we all have to take the next step sometime, so why not take that next step together?

What’s in the videos?
During the series, we will be attempting several more advanced tasks. At present, there is not a lot in the series, but below are some of the highlights from what is available.

Section A: Building a device tree from scratch:
+ Research
+ Finding similar devices
+ Pulling vendor files
+ Setting up a device tree
+ Getting block device information
+ Pulling kernel information
+ Breaking down boot images
+ Build errors
+ Target Assets
+ Tombstones AND MORE!

**** This is an UNOFFICIAL TUTORIAL. Use at your own risk! ****
Now including more than 4 hours of video!

Download links: The video quality is now 1080p!

Ogg Vorbis Video GitLab:
https://gitlab.com/alaskalinuxuser/advanced_course_android_developer_guide
Clicking on a video in GitLab will allow you to watch it online.

Ogg Vorbis Video Downloads:
https://gitlab.com/alaskalinuxuser/advanced_course_android_developer_guide/-/archive/master/advanced_course_android_developer_guide-master.zip
This download is rather large due to the multiple videos.

MP4 Video GitLab:
https://gitlab.com/alaskalinuxuser/advanced_course_android_developer_guide_mp4
Clicking on a video in GitLab will allow you to watch it online.

MP4 Video Downloads:
https://gitlab.com/alaskalinuxuser/advanced_course_android_developer_guide_mp4/-/archive/master/advanced_course_android_developer_guide_mp4-master.zip
This download is rather large due to the multiple videos.

Youtube links: The Youtube quality is now 1080p!
https://www.youtube.com/watch?v=5c66tBsiVVM&list=PLRJ9-cX1yE1nnhWBrZtuVz5YC2OPfQVVp
I am uploading videos. I do have slow internet, so please be patient. Only a portion of videos are uploaded at this time. Upping the quality of the videos have significantly slowed down my ability to upload them.
My device and kernel trees (GitLab) : https://gitlab.com/alaskalinuxuser/

Linux – keep it simple.

Advertisements

Update to Rom/Kernel/TWRP building guide!

Hey everyone!

Just wanted to let you know that I was able to finish and upload another hour worth of videos! That’s right, currently there is more than 9 hours of video tutorial available. As promised, this was added to the series:

* Installing/using VirtualBox
* Fixing a VB Ubuntu problem with screen resolution
* Syncing minimal LineageOS or Omni for building TWRP
* Converting an Omni TWRP device to LineageOS/CM and building it.
* Custom TWRP mods with fonts/icons/splash screens/etc….

twrp

Hope that you are enjoying the series, but mostly, I hope that it is informative and gets you building!
I did try to up the video quality, but I had to tone it back down a bit, as the files became a bit large for uploading and handling. The quality is a little better than the first videos, but not exactly 1080p! 

Thanks again for all of the thanks button slaps and YouTube subscriptions. That lets me know that you guys really appreciate the videos. Be sure to check out my Video Tutorial section in the menu for links to the videos!

Linux – keep it simple.

Video Tutorial on How to Compile Android and Modify Kernels

video

For those interested, I have just posted a video tutorial series on XDA for building Android Oreo, Nougat, Marshmallow, and Lollipop on 5 different phones, the emulator, and 5 different ROMs. Also included are custom kernel editing, adding apps, changing source code, backgrounds, and more. Here’s what I posted:

From XDA: https://forum.xda-developers.com/android/general/guide-how-to-build-custom-roms-kernel-t3814251

===========================================================================

Praise God! Finally a video tutorial of how to build Android and modify kernels!

I have created a video tutorial and guide for how to compile Android, from Lollipop through Marshmallow, Nougat, and Oreo. The video series covers several different phones, the emulator, kernel and rom editing, app source code editing, and much more!

Who is this video series for?
Well, this video tutorial is a step by step guide built primarily for the beginner. This is written for those who already know how to flash TWRP, CWM, or the like, and who have installed a custom rom before. This is designed to help those who are ready to move up from flashing and installing other peoples custom rom to actually start making their own custom roms. I recommend that a beginner watch the entire series in numerical/alphabetical order (the videos are marked).

That said, I believe that an intermediate developer may find a useful trick here and there, and they should just skip ahead to videos of interest. Perhaps kernel development, or something along those lines.

An advanced rom/kernel developer will probably far exceed my feeble abilities, and will not likely find much useful information here. Perhaps if you are an advanced developer, you would consider continuing the tutorial or making an advanced video series! (See further posts for recommendations on contributing videos.)

Why did you put this together?
Well, after building roms for several different devices, I started receiving requests from users who wanted to start building their own roms, but didn’t know how. I didn’t have enough time to answer everyones questions, so I wrote a few guides, pointed others to guides that were available, but there are some things that you just need to see to understand. Hence, the video tutorial. I just hope that someone finds it useful.

This course was written in order! While Lollipop and Marshmallow are old by today’s standards, there is still good learning value in building them, and there are topics covered there that really make them worth watching.

What’s in the videos?
During the series, we will be building for the emulator, as well as 5 different phones of various brands, and 5 different roms. I hope that this will give the viewer a good idea of how to build for their own specific phone as they see the differences and similarities across the phones and custom roms.

[CODE]
+ Ubuntu installation
+ Java installations
+ Using Git, GitHub, GitKraken, and the command line
+ Fastboot and ADB
+ Heimdall/Odin
+ QFIL, QPST, SALT, and other tools
+ AOSP, SlimRoms, PACrom, AOKP, AOSCP
+ Lollipop, Marshmallow, Nougat, Oreo
+ Errors
+ Overclocking CPU/GPU
+ Adding Governors and I/O Schedulers
+ Sound modifications
+ Changing app colors, text, and icons
+ Adding prebuilt apps
+ Adding source code
+ Converting device from one rom to another
+ AND MORE!
[/CODE]

**** This is an UNOFFICIAL TUTORIAL. Use at your own risk! ****
Download links:
Ogg Vorbis Video GitLab:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide[/url]
Clicking on a video in GitLab will allow you to watch it online.

Ogg Vorbis Video Downloads:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide/-/archive/master/course_android_developer_guide-master.zip[/url]
This download is rather large due to the multiple videos.

MP4 Video GitLab:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide_mp4[/url]
Clicking on a video in GitLab will allow you to watch it online.

MP4 Video Downloads:
[url]https://gitlab.com/alaskalinuxuser/course_android_developer_guide_mp4/-/archive/master/course_android_developer_guide_mp4-master.zip[/url]
This download is rather large due to the multiple videos.

I also have several written guides available on XDA, here are a few:

Building ROMs for the Galaxy Note Edge: [url]https://forum.xda-developers.com/note-edge/general/guide-build-aosp-roms-kernels-note-edge-t3488840[/url]
Building ROMs for the Galaxy S4: [url]https://forum.xda-developers.com/galaxy-s4-tmobile/general/guide-step-step-instructions-building-t3402637[/url]

===========================================================================

Be sure to check out the videos or the XDA thread! I hope that these will help some of the aspiring Android developers out there!

Linux – keep it simple.

Geany: the little IDE that could!

geany_ide.png

Recently, while working with some older equipment, I needed a lightweight java IDE to compile some java projects. I really wasn’t looking for something quite as big as eclipse or netbeans, I just wanted a simple, one stop solution that would allow me to build java programs on an older laptop.

So, I rubbed a magic lamp, and out popped Geany!

Well, more specifically, the laptop is running Debian Wheezy, and had openJDK already installed. With that alone, I could have built java programs from the command line, but it can get a little tedious. So, I looked on the repositories for an IDE that wasn’t too large.

Thus enter Geany. I first used Geany a long time ago as a text editor on #! (CrunchBang) Linux, but revisiting the program revealed that I was not using it to it’s full potential. Specifically, you can compile, build, and run various program types from within Geany. Of course, it only outsources the commands for you, so you need a java jdk in order to compile java, or a c++ compiler to compile c++. Geany just does all the command line work for you.

What Geany does accomplish for you, however, is a great user interface with templates and the ability to organize projects or view code with different filters. As you can see in the picture, I was testing out Logic Crazy’s Alpha Beta Chess program.

As well as showing you the code, it can do parenthesis highlighting, colors for different code type, and a class and method tree on the side. It really is a great program if you need a lightweight IDE. I know that I’ll be putting it to good use.

Linux – keep it simple.

Building Android Oreo, error: ADDITIONAL_DEFAULT_PROPERTIES must not be set

So, round one of building Android Oreo. Specifically giving an early try for SlimRoms and OmniRom, both of which have started an Oreo build system. Obviously, anything at this stage is a pre-alpha, more or less just a rebranded AOSP build. Still, it’s fun to check it out and see what Oreo is all about.

That being easier said than done, here was the first error (not counting all the ones to set up the build environment to recognize the H811 phone as an option) :

[CODE]
out/build-slim_h811.ninja is missing, regenerating…
build/core/main.mk:245: error: ADDITIONAL_DEFAULT_PROPERTIES must not be set before here: ro.device.cache_dir=/data/cache.
07:23:13 ckati failed with: exit status 1
make: *** [run_soong_ui] Error 1
[/CODE]

So, I took a look at build/core/main.mk on line 245, and made a few edits:

[CODE]
#
# —————————————————————–
# Validate ADDITIONAL_DEFAULT_PROPERTIES.
# WJH ifneq ($(ADDITIONAL_DEFAULT_PROPERTIES),)
# WJH $(error ADDITIONAL_DEFAULT_PROPERTIES must not be set before here: $(ADDITIONAL_DEFAULT_PROPERTIES))
# WJH endif
[/CODE]

Now the build can continue. This is probably not the right way to fix this, but it is an easy bandaid until I figure that out.

Linux – keep it simple.

 

error: undefined reference to ‘wifi_start_fstman’

Ah, the continuing saga of the far far away dream of building OmniRom Nougat for the LG G4. Yet again, another set of errors:

[CODE]
system/qcom/softap/sdk/qsap.c:705: error: undefined reference to ‘wifi_start_fstman’
system/qcom/softap/sdk/qsap.c:714: error: undefined reference to ‘wifi_stop_fstman’
system/qcom/softap/sdk/qsap.c:722: error: undefined reference to ‘is_fst_enabled’
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
[/CODE]

So I took a look at the lines in question of system/qcom/softap/sdk/qsap.c:

[CODE]
int qsap_prepare_softap()
{
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
}

int qsap_unprepare_softap()
{
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
}

int qsap_is_fst_enabled()
{
return is_fst_enabled();
}
[/CODE]

No big deal, I thought. I could just wrap them in an #ifdef (if defined) statement, and only use them if they are actually defined. So I did.

[CODE]
int qsap_prepare_softap()
{
/* WJH */
#ifdef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
#endif
}

int qsap_unprepare_softap()
{
/* WJH */
#ifdef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
#endif
}

int qsap_is_fst_enabled()
{
/* WJH */
#ifdef is_fst_enabled
return is_fst_enabled();
#endif
}
[/CODE]

You are all probably smarter than me, and see the error of my ways, but non the less, I ran it as so, and this was my next set of errors:

[CODE]
system/qcom/softap/sdk/qsap.c:707:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
system/qcom/softap/sdk/qsap.c:716:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
system/qcom/softap/sdk/qsap.c:724:1: error: control reaches end of non-void function [-Werror,-Wreturn-type]
}
^
[/CODE]

The problem was that the in int qsap_is_fst_enabled(), int qsap_unprepare_softap(), and int qsap_prepare_softap() integers all return nothing, or are “null”. That’s no good for follow on code, they have to have some value. So, I thought about it for a while, and right or wrong, I decided to use an #ifndef (if not defined) flag.
If the functions were defined, they would be used, if they are not defined, then I gave a return value, arbitrary as they may be, but what I suspect is the “right answer”. Take a look:

[CODE]
int qsap_prepare_softap()
{
/* WJH */
#ifdef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return wifi_start_fstman(TRUE);
#endif
#ifndef wifi_start_fstman
ALOGD(“Starting fstman\n”);
return 1;
#endif
}

int qsap_unprepare_softap()
{
/* WJH */
#ifdef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return wifi_stop_fstman(TRUE);
#endif
#ifndef wifi_stop_fstman
ALOGD(“Stopping fstman\n”);
return 1;
#endif
}

int qsap_is_fst_enabled()
{
/* WJH */
#ifdef is_fst_enabled
return is_fst_enabled();
#endif
#ifndef is_fst_enabled
return 0;
#endif
}
[/CODE]

And viola! This time it worked. What result that will have in the end? I’m not sure. Hopefully it still functions properly, but that remains to be seen….

Linux – keep it simple.

 

Function “appears in overlay but not in the base package”

Ah, OmniRom. Yes, I am still working on it. Hopefully you are not getting tired of these errors, but I find it helpful to log them here, and hopefully others will also. Previously, we looked at ways to use <add-resource> to add functions into a rom, but here we are just going to disable an overlay that we can work on later.

[CODE]
FAILED: /bin/bash -c “(touch out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && ((cd out/target/common/obj/APPS/framework-res_intermediates/ && jar cf package-export.apk zipdummy) ) && (zip -qd out/target/common/obj/APPS/framework-res_intermediates/package-export.apk zipdummy ) && (rm out/target/common/obj/APPS/framework-res_intermediates/zipdummy ) && (out/host/linux-x86/bin/aapt package -u -x –private-symbols com.android.internal -z –pseudo-localize -M frameworks/base/core/res/AndroidManifest.xml -S device/lge/g4-common/overlay/frameworks/base/core/res/res -S frameworks/base/core/res/res -A frameworks/base/core/res/assets –min-sdk-version 25 –target-sdk-version 25 –product default –version-code 25 –version-name 7.1.2 –skip-symbols-without-default-localization -F out/target/common/obj/APPS/framework-res_intermediates/package-export.apk )”
device/lge/g4-common/overlay/frameworks/base/core/res/res/values/config.xml:277: error: Resource at config_supportDoubleTapWake appears in overlay but not in the base package; use <add-resource> to add.
[/CODE]

So, as you can see, we have something in our overlay that is supposed to lay over the top of some source code, but the base source code doesn’t have that function to be “overlayed”. Here is where we see the overlay in device/lge/g4-common/overlay/frameworks/base/core/res/res/values/config.xml:277:

[CODE]
<!– Whether device supports double tap to wake –>
<bool name=”config_supportDoubleTapWake”>true</bool>
[/CODE]

So, we changed it to:

[CODE]
<!– Whether device supports double tap to wake
<bool name=”config_supportDoubleTapWake”>true</bool> WJH –>
[/CODE]

By commenting it out, it will no longer “overlay” it onto something that doesn’t exist. Be sure to take a look at my other article for how to use <add resource> to actually add an overlay item to the base package.

Linux – keep it simple.

 

Failed to mmap at expected address

In the continuing OmniRom saga, another day with another fail:

[CODE]FAILED: /bin/bash -c “(mkdir -p out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/ && rm -f out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (find out/target/common/obj/APPS/CaptivePortalLogin_intermediates/ -maxdepth 1 -name \”classes*.dex\” | sort | xargs zip -0qjX out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (mv out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input ) && (rm -f out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex ) && (mkdir -p out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/ ) && (ANDROID_LOG_TAGS=\”*:e\” out/host/linux-x86/bin/dex2oatd –runtime-arg -Xms64m –runtime-arg -Xmx512m –runtime-arg -classpath –runtime-arg \”&\” –boot-image=out/target/product/h811/dex_bootjars/system/framework/boot.art –dex-file=out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input –dex-location=/system/app/CaptivePortalLogin/CaptivePortalLogin.apk –oat-file=out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex –android-root=out/target/product/h811/system –instruction-set=arm64 –instruction-set-variant=generic –instruction-set-features=default –include-patch-information –runtime-arg -Xnorelocate –no-generate-debug-info –abort-on-hard-verifier-error –no-inline-from=core-oj.jar   –compile-pic ) && (rm out/target/product/h811/obj/APPS/CaptivePortalLogin_intermediates/oat/arm64/package.odex.input )”dex2oatd E 16505 16505 art/runtime/gc/heap.cc:324] Could not create image space with image file ‘out/target/product/h811/dex_bootjars/system/framework/boot.art’. Attempting to fall back to imageless running. Error was: Failed to load /system image ‘out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art’: Failed to mmap at expected address, mapped at 0x2b038dbfd000 instead of 0x70ddd000 : Requested region 0x70ddd000-0x70dde000 overlaps with existing map 0x70ddd000-0x70dde000 (/home/alaskalinuxuser/compile/20170727_aospa7/out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art)dex2oatd E 16505 16505 art/runtime/gc/heap.cc:324] 0x70ddd000-0x70dde000 rw- /home/alaskalinuxuser/compile/20170727_aospa7/out/target/product/h811/dex_bootjars/system/framework/arm64/boot-telephony-ext.art[/CODE]
It took me a while to figure this out, but the heart and soul of this problem lies with ART’s AOT (Ahead Of Time) preoptimization. Fortunately, I found a helpful tidbit on how to disable the preoptimization of this app. I did so here, in the /frameworks/base/packages/captiveportallogin/AndroidManifest.xml file:

[CODE]
    <application android:label=”@string/app_name” android:vmSafeMode=”true” >        <activity            android:name=”com.android.captiveportallog
[/CODE]
By adding android:vmSafeMode=”true”, the AOT of ART is disabled for this app. You can read more about that here: https://developer.android.com/guide/topics/manifest/application-element.html#vmSafeMode
Linux – keep it simple.

To skia or not to skia?

What is skia? Well, skia is used for drawing 2d graphics, and that is pretty important in Android.
More specifics can be read here at their website.
Essentially, it is used for making menus and drawings.

Now you are wondering why we are talking about it. Well, because we had an error:

[CODE]
ninja: error: ‘out/target/product/h811/obj_arm/STATIC_LIBRARIES/libqc-skia_intermediates/libqc-skia.a’, needed by ‘out/target/product/h811/obj_arm/SHARED_LIBRARIES/libskia_intermediates/LINKED/libskia.so’, missing and no known rule to make it
[/CODE]

As it turns out, the open source skia project was forked and some closed material was added for specific hardware, like qcom boards. So, with a few edits in ./external/skia/Android.mk, we changed it to go back to using the open source method, rather than qual comm’s specific one. All that is lost is a little bit of efficiency on qcom chips, which is actually important, but not more important than working at all.

[CODE]
#ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
# LOCAL_WHOLE_STATIC_LIBRARIES += libqc-skia
#endif
# WJH
[/CODE]

A few comments here and there, keeping it from checking if the board is a qcom board allows us to build and use the open source variant. Simple!

Linux – keep it simple.

use BUILD_PREBUILT instead!

OmniRoms Nougat. An elusive dream of mine is building OmniRoms for my devices. In the past I just couldn’t seem to get them to work. Well, I have decided to give it another go, and here was one of my first errors:

[CODE]
build/core/Makefile:34: *** Prebuilt apk found in PRODUCT_COPY_FILES: vendor/lge/g4-common/proprietary/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk:system/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk, use BUILD_PREBUILT instead!.
[/CODE]

So, I took a look at g4-common-vendor-blobs.mk:

[CODE]
vendor/lge/g4-common/proprietary/lib/libloc_ds_api.so:system/lib/libloc_ds_api.so \
vendor/lge/g4-common/proprietary/lib/libalhdri.so:system/lib/libalhdri.so \
vendor/lge/g4-common/proprietary/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk:system/priv-app/qcrilmsgtunnel/qcrilmsgtunnel.apk \
vendor/lge/g4-common/proprietary/vendor/firmware/libpn547_fw_C9.so:system/vendor/firmware/libpn547_fw_C9.so \
vendor/lge/g4-common/proprietary/vendor/firmware/BCM4335_003.001.009.0117.0620_LGE_P1_EU.hcd:system/vendor/firmware/BCM43…..
[/CODE]

Here we can see that the file in question “qcrilmsgtunnel.apk” is being copied over with the vendor blobs. The error is telling us that we need to install it as a prebuilt app, instead of copying the app over as a normal file. So, I edited out that line in the g4-common-vendor-blobs.mk file, and edited g4-common-vendor.mk by adding it like so:

[CODE]
PRODUCT_PACKAGES += \
qcrilmsgtunnel \
qcnvitems \
qcrilhook
[/CODE]

Notice that I did not move the apk file around, just redefined how to get it moved into the rom. Well, that took care of that error! 1 down, untold dozens to go!

Linux – keep it simple.