Build AOSP for Pixel 3 XL

The AOSP build process is fairly well understood by now: sync the source code, add device-specific drivers and kernel, and build the target image. I had built AOSP before to debug certain issues, but official support for Pixel 3 XL only goes up to Android 12. Recently, while working on Chromium development, I needed to test WebView on a newer platform, so I used LineageOS 21 for the build instead. ...

August 15, 2022 · 2 min · haoxiqiang

Jenkins Setup Notes

I was working on an overseas application whose build server was originally located in Shanghai. Due to special circumstances, it needed to be migrated abroad. This post documents the Jenkins migration and configuration process. Prerequisite: Install JDK 11 Using jenv for multi-version Java management: 1 2 3 4 5 6 7 8 9 # Install jenv git clone https://github.com/jenv/jenv.git ~/.jenv echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(jenv init -)"' >> ~/.bashrc source ~/.bashrc # Enable the export plugin and restart the session jenv enable-plugin export exec $SHELL -l Installing Jenkins on CentOS 1 2 3 4 5 6 # Add Jenkins repository and GPG key sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key # Install yum install jenkins Configuring systemd Service 1 2 3 4 sudo vi /etc/systemd/system/jenkins.service sudo systemctl enable /etc/systemd/system/jenkins.service sudo systemctl start jenkins systemctl status jenkins 1 2 3 4 5 6 7 8 9 10 11 12 13 [Unit] Description=jenkins service After=network.target [Service] Type=simple LimitNOFILE=65536 ExecStart=/usr/bin/jenkins User=work Environment="JENKINS_PORT=8082" [Install] WantedBy=multi-user.target Configuring Android SDK 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 wget https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip unzip commandlinetools-linux-8512546_latest.zip chmod a+x cmdline-tools/ cd cmdline-tools/bin # Install required components via sdkmanager ./sdkmanager --sdk_root=/home/work/workspace/android_sdk --list ./sdkmanager --install 'platforms;android-33' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'build-tools;33.0.0' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'cmdline-tools;7.0' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'build-tools;32.0.0' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'build-tools;31.0.0' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'ndk;25.1.8937393' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'platforms;android-28' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'platforms;android-29' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'platforms;android-30' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'platforms;android-31' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'cmake;3.22.1' --sdk_root=/home/work/workspace/android_sdk ./sdkmanager --install 'cmake;3.10.2.4988404' --sdk_root=/home/work/workspace/android_sdk Fixing SSH Key Permission Issues If you encounter Permissions 0664 for '/home/work/.ssh/jenkins_id_rsa' are too open: ...

June 6, 2022 · 2 min · haoxiqiang

Optimizing Android Builds with Self-Hosted Nexus Repository

In Android dependency management, it’s common to configure multiple remote repositories like jcenter, jitpack, google(), and more. Some large projects, such as “Zuiyou”, depend on over 10 repositories. This becomes a significant problem during initial project setup, dependency changes, or network issues — troubleshooting builds becomes a nightmare. I had noticed this issue long ago but kept putting off addressing it. This post documents the Nexus setup process. Installing and Configuring Nexus Prerequisite: JDK 8+. ...

December 31, 2019 · 2 min · haoxiqiang

Android & Linux Tips Collection #3

Three quick tips: handling the back button in DialogFragment, chmod permission reference, and the underscore problem in SSL hostnames. DialogFragment Back Button Handling DialogFragment has no direct override for the back button. Two approaches were commonly used. Approach 1: Override in onCreateDialog 1 2 3 4 5 6 7 8 9 @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new Dialog(getActivity(), getTheme()){ @Override public void onBackPressed() { // Handle back press here } }; } Approach 2: Via onKeyListener 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 @Override public void onResume() { super.onResume(); Dialog dialog = getDialog(); if (dialog != null) { dialog.setOnKeyListener(this); } } @Override public void onPause() { super.onPause(); Dialog dialog = getDialog(); if (dialog != null) { dialog.setOnKeyListener(null); } } Modern Approach: OnBackPressedDispatcher (AndroidX) For newer versions, use AndroidX’s OnBackPressedDispatcher. Since Fragment 1.6.1, DialogFragment returns a ComponentDialog by default, which has its own OnBackPressedDispatcher: ...

April 5, 2017 · 3 min · haoxiqiang

Android MediaStore: GROUP BY via ContentResolver

When building a photo album feature similar to WeChat, I needed to read photos and videos with multi-folder switching — and it had to be faster than WeChat. After some research, the MediaStore approach proved most suitable. Since I hadn’t used it much before, this post serves as a record. The GROUP BY Hack in ContentResolver ContentResolver.query() does not expose a groupBy parameter (unlike SQLiteQueryBuilder.query()), but you can achieve a similar effect by embedding GROUP BY directly into the selection argument. ...

March 31, 2017 · 2 min · haoxiqiang

HTTPS Notes

Before working with HTTPS, I recommend reading Android Training: Security with SSL. Many companies have adopted full-site HTTPS, but not all implementations are correct. This post records some issues I encountered. ...

January 20, 2016 · 3 min · haoxiqiang

Android Issues Roundup (Part 2)

Second batch of collected issues, mainly covering WebView memory management, cookie synchronization, and other development details. ...

January 19, 2016 · 3 min · haoxiqiang

Building an App with RxJava

I’ve been working on a Zhihu Daily client to evaluate RxJava’s benefits and trade-offs in a real project. RxJava has gained significant traction abroad, with language bindings spanning Java, JavaScript, C#, Scala, Clojure, C++, Python, Ruby, Kotlin, Swift, and more. ...

January 7, 2016 · 2 min · haoxiqiang

Android Development Issues and Solutions

After reading some issue roundups on Xiaoke’s Blog, I realized I’ve encountered many of the same problems. Here’s a collected summary. ...

December 29, 2015 · 5 min · haoxiqiang

Android Resource Shrinking

While building a project, I discovered the shrinkResources attribute, which removes unused resources from the APK. Here is how to configure it and what to watch out for. ...

December 23, 2015 · 2 min · haoxiqiang