Showing posts with label Ubuntu Linux. Show all posts
Showing posts with label Ubuntu Linux. Show all posts

29 October, 2025

Building Android from Source (AOSP 15) on Lenovo ThinkBook 16p G5 IRX

🚀 Building Android from Source (AOSP 15) on Lenovo ThinkBook 16p G5 IRX

Author: Porfy Vidal
Platform: Ubuntu 22.04 LTS
Target: AOSP 15 (Vanilla Ice Cream, Cuttlefish Emulator)


🧩 1. System Overview

After multiple rebuilds and optimizations, this guide shows the complete setup for a working AOSP 15 development environment on the Lenovo ThinkBook 16p G5 IRX with Ubuntu 22.04.

Key goals:

  • Compile AOSP 15 from source
  • Run Cuttlefish emulator (x86_64 phone)
  • Enable ADB access and app installation
  • Automate system maintenance tasks

⚙️ 2. Preparing Ubuntu 22.04

Install the essentials and developer tools:

sudo apt update && sudo apt install -y \

  openjdk-17-jdk python3 git-core gnupg flex bison gperf build-essential \

  zip curl zlib1g-dev libc6-dev libncurses5-dev libncurses5 \

  x11proto-core-dev libx11-dev libgl1-mesa-dev libxml2-utils xsltproc unzip \

  fontconfig repo ccache

Optional (but useful) developer tools:

sudo apt install -y htop nvtop iotop baobab gnome-disk-utility gparted \

  vim nano gnome-tweaks filezilla qbittorrent chrome-gnome-shell


🧰 3. Set Up the AOSP Source Tree

mkdir ~/aosp15

cd ~/aosp15

repo init -u https://android.googlesource.com/platform/manifest -b aosp-main

To sync specific components only (faster iteration):

repo sync -j1 --fail-fast external/ComputeLibrary external/apache-harmony \

external/aws-sdk-java-v2 prebuilts/remoteexecution-client prebuilts/tools

Expected output:

repo sync has finished successfully.


🧱 4. Build Configuration

cd ~/aosp15

source build/envsetup.sh

Choose the target build:

lunch aosp_cf_x86_64_phone-trunk_staging-userdebug


🖥️ 5. Installing Cuttlefish Emulator Packages

Download the following from the official AOSP Cuttlefish build server:

cvd-host_package.tar.gz

aosp_cf_x86_64_only_phone-img-14253210.zip

Extract them:

mkdir ~/cuttlefish

tar -xzf ~/Downloads/cvd-host_package.tar.gz -C ~/cuttlefish

unzip ~/Downloads/aosp_cf_x86_64_only_phone-img-14253210.zip -d ~/cuttlefish

Verify images exist:

ls ~/cuttlefish | grep img

You should see:

boot.img

init_boot.img

super.img

userdata.img

vendor_boot.img

...


🧪 6. Launching the Emulator

cd ~/cuttlefish/bin

./launch_cvd

Once launched, check ADB connectivity:

adb devices

Expected:

List of devices attached

0.0.0.0:6520	device

Open an interactive shell:

adb shell


📦 7. Installing Apps via ADB

To install an APK:

adb install MyApp.apk

For .xapk packages:

  1. Unzip the .xapk.
  2. Find the contained .apk file.
  3. Install it:
adb install app.apk


🧼 8. System Maintenance Automation

Create /usr/local/bin/sysrefresh to automate updates and cleanup:

#!/bin/bash

echo "============================================="

echo "🕒 System refresh started at: $(date)"

echo "============================================="



echo "🔄 Checking for package updates..."

UPDATES=$(apt list --upgradable 2>/dev/null | grep -v Listing | wc -l)

if [ "$UPDATES" -eq 0 ]; then

  echo "☑️  No updates were needed. System is already up to date."

else

  echo "🛠️  Installing updates..."

  sudo apt update && sudo apt upgrade -y

fi



echo "🧹 Performing cleanup..."

sudo apt autoremove -y

sudo apt autoclean -y



echo "🧠 Disk space usage summary:"

df -h | grep -E '^/dev/nvme|Filesystem'

echo "---------------------------------------------"

echo "✅ Last refresh completed: $(date)"

echo "---------------------------------------------"

echo "🟢 sysrefresh complete."

Make it executable:

sudo chmod +x /usr/local/bin/sysrefresh

Run it any time:

sysrefresh


🖥️ 9. Display Configuration

Switching to Xorg restored full dual-monitor support.

Current setup:

  • Internal display: eDP-1 (3200×2000)
  • External monitor: HDMI-1-0 (3840×2160)

Dual display:

xrandr --output eDP-1 --primary --mode 3200x2000 --pos 0x0

xrandr --output HDMI-1-0 --mode 3840x2160 --right-of eDP-1 --scale 0.5x0.5

External only:

xrandr --output eDP-1 --off --output HDMI-1-0 --auto

Internal only:

xrandr --output HDMI-1-0 --off --output eDP-1 --auto


🧩 10. Summary of Achievements

  • ✅ AOSP 15 environment successfully built
  • ✅ Cuttlefish emulator running smoothly
  • ✅ ADB functional for app install and testing
  • ✅ Automated maintenance script (sysrefresh)
  • ✅ Dual-display working under Xorg
  • ✅ Optimized Ubuntu 22.04 for development

💡 Final Thoughts

This setup transforms the ThinkBook 16p G5 IRX into a powerful Android development workstation. While the process takes patience, once configured, the environment is stable and production-ready.

“Building Android from source isn’t just about compiling code — it’s about understanding the entire ecosystem.”


Guidance provided with the help of ChatGPT (OpenAI) 

Till then!

02 May, 2014

Fixing BCM4352 driver in Ubuntu Linux

Broadcom
Broadcom (Photo credit: Wikipedia)
02-May-2014

I needed to reinstall Ubuntu Linux 14.04 Trusty Tahr in my laptop, as the program that I needed to use doesn't run. I believe I messed it up - part of my learning, I would say.

As in my previous installation, the Wireless  Network Adapter wasn't working, and that is the one I had to fix first and foremost.

I searched again, and I don't think I found the same article that I used before, but now, I used one which I followed to the letter, and after reboot, I find that the Wi-Fi connection is still not working.

Since I had to go and send my K1 girl off to school, I shut down the computer. And my wife and I had to go to the grocery to grab some things. A couple of hours, we were back.

Computer Home Business

So now I am on my second time to start the laptop after installation. I tinkled with the system settings, specifically on the profile photo, date and time settings, battery life indicator, etc. When I came to the 'Software & Updates section, I did my usual tinkering, checked the boxes on the Other Software and Updates tabs, and surprisingly, coming to the Additional Drivers tab, there was a choice to use the proprietary driver for the Broadcom wireless network card. That means what I installed was recognized by the system!

So, I have to take note of it now, lest I can't find it again should the need arise - to reinstall once again, or do another box.

Here's the link: Fixing Broadcom BCM43xx cards Ubuntu 10.04 and later

Hope this helps others who would run into the same problem: my machine is HP Envy-15 TS.

Till then!

Enhanced by Zemanta

23 April, 2014

Windows 8.1 and Ubuntu Linux 14.04

linux_inside
linux_inside (Photo credit: Adriano Gasparri)
23-April-2014

After I conquered my fear of Java, thanks to the book Java 7 for Absolute Beginners, I was thinking, what now? I was just so relieved that Java turned out to be so similar, to be precise, so close, to C#, 95%-99% identical, with the 'struct' as main difference, and of course, the way things are called and named.

No big deal, but I actually enjoyed learning Java, or at least, the first book that I grabbed gave me a good impression of Java. And thanks to my desire to learn Java, I now understand C# better. I am now on my second Java (Programming) book.

In some days after I finished the book, and typing the codes, and making them run, I got familiar somehow with Eclipse, IntelliJ and NetBeans editors. And that is when I thought, anything else?

Alongside Java, I also was intimidated by Unix, and with that, Perl. Like I said in my previous articles, I just can't 'grep' the things in Unix, and whenever I sat infront of a Unix terminal, I felt so 'awk'-ward.

Well, things have changed. First is Java. Now, Linux. Yap. Linux. Ubuntu. I managed to go with the VirtualBox thing, and yes, it was running in Windows 8, and also in Windows 7 (the latter already known).

The thing with my new machine is that it is UEFI-enabled, so I followed some blogs, forums and articles, and I tweaked and tweaked and tweaked, owing to the fact that I both have UEFI and Safe Boot flags to deal with, but these are just dealing with time, nothing much on hard thinking.

Anyway, I managed to get my Windows 8.x machine to boot on the USB stick, and I was off 'trying' Ubuntu. So to say, I run my 'Hello, world' program, but I found that the Broadcom WiFi card isn't working.

It was at this point that I tried using the same USB stick to try Ubuntu Linux in my other laptop, which is already going 6 years, and voila! Everything was working, including the WiFi. Which means that Ubuntu is okay, but in my new machine, there is some minor problem.

And I find it funny, that in my need to be connected, only at this time, after about 6 months, I found that my HP Envy 15, slim as it is, was still fitted with an RJ 45 plug, so I was still able to connect to the internet.

I did some cleaning in my HDD, for my mind is made up: I will attempt to do a dual-boot on my Windows 8.x laptop. When it came to defragmenting the drive to compress the data in it, I didn't find the native defragmenter in Windows to be doing the job. I searched, and I found some, like Smart Defrag, Perfect Disk, and the feature I needed was in PerfectDisk, just glad that their 30-day trial let me do the empty space compression and 'Prep for Shrink'. But I used Smart Defrag to set a defragmentation of the MFT and other system files on boot.

Again, when it was time to do the partitioning, I found that the built-in utility in Windows is lacking. As in the past, I used Partition Wizard Home Edition, and that software gave me the freedom to do what I needed to do.

I almost got mixed up in the file naming, or drive naming, to be more precise, between Windows and Linux. This was my first attempt, and I am having no back-up disc for my Windows OS, but when it comes to doing things like this, I am one who takes the risk. And not without rewards!

I got myself a bit familiar with the Ubuntu Linux installer, and I exercised my power of observation. I had to look at all that is being shown in the installer GUI, for I can't be mistaken with my selection. I think I re-run 3 times before finally proceeding.

To be precise, there were 3 partitions, the 1GB for the boot record, the 10GB for the swap file, and the 75GB for the Linux OS/kernel. Fortunately, the installer has the bar graph at the top that showed the physical layout - hey, I'm a newbie when it comes to Linux, and the success of anything is that anybody can follow it, even without a manual. And I did!

But a point to note: the installer is supposed to detect the existing Windows OS installation, but Windows 8.x being new and all, it wasn't. So as advised in many forums, back when it was Windows 7's being new in the computing world, the same rule applies: choose 'Something else', and you will have to manually configure the succeeding pages. I went through all that, and I managed to complete the installation.

Reboot, and as expected, I did not see GRUB, so I defaulted to pressing F9 so that I can choose which OS to run. And yes, Linux is so damn fast. This post is being generated in Firefox inside Linux, by the way. Actually, I am spending more time using Linux than Windows in the past couple of days. But to be fair, I salute Windows 8, which is by far the best in the breed (Windows 3, XP, 95, 98, 7, etc.) I like best the fast boot feature. But IE11 sucks so much, I hated it.

That was it for my Windows 8.x machine, and when I did the dual-boot attempt on my 14-year old Acer desktop PC, it was able to detect the existing Windows installation, so I selected 'install alongside Windows'. And when I almost would have said that my cleaning and partitioning effort for that old machine (yes, I had to uninstall many applications) was for naught, I found that even the empty partition was stored in some file used by Ubuntu Linux!

I found out about it when after checking that usage for the 10GB partition was 0%, I tried to merge it to the kernel drive, but failed. So I left it as unallocated. Because you see, the installation process, running entirely on its own, cut away the 10GB space for the swap file from the partition intended for the kernel, so I was just 'giving it back' the space.

Then after a reboot, I got an error, Ubuntu reported some 'unrecognized disk' and it stopped at some _grub prompt. Hey, I'm new to Linux, so what do I know?

I did a cold shutdown, and performed the reinstallation, did the whole thing again, and after a reboot, to confirm that even with the unallocated disk still unallocated, the problem is gone - and it was so!

I now have 2 machines running Ubuntu Linux 14.04. And while only the old machine is able to boot on GRUB, I am contented with being able to boot my Windows 8.x machine suing boot option manually.

And I managed to fix the WiFi error, with some guide drawn out by super users which isn't really that hard to follow, so now I am running wireless on Linux.

This post is coming from Ubuntu Linux 14.04. I will miss Windows...

Till then!


Enhanced by Zemanta