Repository: nathanchance/Android-Tools
Branch: main
Commit: 90a4ff9291e6
Files: 5
Total size: 17.4 KB
Directory structure:
gitextract_i2v0kt5d/
├── README.md
├── guides/
│ ├── building_aosp.txt
│ └── proper_bug_reporting.txt
└── scripts/
├── bldgcc
└── haste
================================================
FILE CONTENTS
================================================
================================================
FILE: README.md
================================================
# Android Tools
This repository contains public guides and scripts tailored for custom Android Development. The scripts have comments throughout
them telling you what you need to edit but you are required to have functional knowledge of terminal.
## Contents:
- [AOSP Building Guide](guides/building_aosp.txt)
- [Bug Reporting](guides/proper_bug_reporting.txt)
================================================
FILE: guides/building_aosp.txt
================================================
###########################
# #
# MAY 31, 2021 UPDATE #
# #
###########################
This guide is no longer being actively maintained or updated, as I have not
built an Android ROM since 2017 or even used an Android device as my daily
driver since 2019. I am leaving it up as it has been useful for many but you
might want to check out some more updated guides, such as those below:
https://source.android.com/setup/build/building
https://wiki.archlinux.org/title/Android#Building
https://wiki.lineageos.org/build_guides.html
####################################
# #
# BUILDING ANDROID FROM SOURCE #
# #
####################################
In this guide, I will go over how to build Android on your Linux machine.
This particular tutorial will focus on Ubuntu flavors but this should work with
any version of Linux; I include a reference for Arch users that is already done.
Your version MUST be 64-bit however. I will leave the installation of that up
to you, Google is a wonderful resource. If you don't have a good computer but
still want to build, check out this thread on XDA:
http://forum.xda-developers.com/chef-central/android/guide-how-to-build-rom-google-cloud-t3360430
Formatting!!!
If something has a $ in front of it, that is a command you need to run in your
terminal window. Don't include the $ or the space that follows it.
#######################################
# Step One: set up your environment #
#######################################
You have two options here, the lazy way or the non-lazy way.
Automatic way (recommended!):
-- Grab a repo with some useful scripts, and run the needed one
$ sudo apt-get install git-core
$ git clone https://github.com/akhilnarang/scripts
$ cd scripts
$ ls
$ bash setup/<script-name>
Run the script corresponding to your Linux Distribution:
arch-manjaro.sh - Arch based distros
android_build_env.sh - Ubuntu 14, Ubuntu 16, Ubuntu 18, Mint 19
Manual way:
-- Grab Java 8:
$ sudo apt-get update
$ sudo apt-get install openjdk-8-jdk
$ sudo apt-get install openjdk-8-jre
-- Install build tools
$ sudo apt-get install bc bison build-essential ccache curl flex \
g++-multilib gcc-multilib git-core gnupg gperf imagemagick lib32ncurses5-dev \
lib32z-dev libc6-dev-i386 libgl1-mesa-dev libssl-dev libx11-dev \
libxml2-utils unzip x11proto-core-dev xsltproc zip zlib1g-dev
NOTE: Arch Linux users, use the Arch wiki page to install your packages then
come back here: https://wiki.archlinux.org/index.php/Android#Building_Android
######################################
# Step Two: Configure Repo and Git #
######################################
NOTE: If you have any problems with the below commands, try running as root:
$ sudo -s
Git is an open source version control system which is incredibly robust for
tracking changes across repositories. Repo is Google's tool for working with Git
in the context of Android. More reading if you are interested:
https://source.android.com/source/developing.html
Run these commands to get repo all working (only needed if you did the manual
method of setup above):
$ curl https://storage.googleapis.com/git-repo-downloads/repo > repo
$ chmod a+x repo
$ sudo install repo /usr/local/bin
$ rm repo
Then run these commands to get git all working:
$ git config --global user.name "Your Name"
$ git config --global user.email "you@example.com"
#####################################
# Step Three: Download the source #
#####################################
First, create a folder for your source:
$ mkdir ~/<foldername> (eg. mkdir ~/DU or ~/PN-Layers)
$ cd ~/<foldername>
When you go to build a ROM, you must download its source. All, if not most,
ROMs will have their source code available on Github. To properly download the
source, follow these steps:
-- Go to your ROM's Github (e.g. http://github.com/DirtyUnicorns)
-- Search for a manifest (usually called manifest or android_manifest).
-- Go into the repo and make sure you are in the right branch (located right
under the Commits tab).
-- Go into the README and search for a repo init command. If one exists, copy
and paste it into the terminal and hit enter.
-- If one does not exist, you can make one with this formula:
repo init -u <url_of_manifest_repo>.git -b <branch_you_want_to_build>.
For example:
$ repo init -u https://github.com/DirtyUnicorns/android_manifest.git -b o8x
-- After the repo has been initialized, run this command to download the source:
$ repo sync --force-sync -j$( nproc --all )
-- This process can take a while depending on your internet connection.
##########################
# Step Four: Build it! #
##########################
Here's the moment of truth... time to build the ROM! This process could take
15 minutes to many hours depending on the speed of your PC but assuming that
you have followed the instructions so far, it should be smooth sailing.
Before you compile, you may also consider setting up ccache if you can spare
about 50GB. If not, skip this section. ccache is a compiler cache, which keeps
previously compiled code stored so it can be easily reused. This speeds up
build times DRASTICALLY.
Open your bashrc or equivalent:
$ nano ~/.bashrc
- Append export USE_CCACHE=1 to the end of this file
then hit ctrl-X, Y, and enter.
$ source ~/.bashrc
After that, run this command if you used the manual method of setup above
$ prebuilts/misc/linux-x86/ccache/ccache -M 50G (or however much you want).
Run this command if you used the automatic method of setup above
$ ccache -M 50G
Since Android 10, the way of using ccache has changed:
$ export USE_CCACHE=1
$ export CCACHE_EXEC=$(command -v ccache)
After this, load up the compilation commands:
$ . build/envsetup.sh
Then, tell it which device you want to make and let it roll:
$ breakfast <device> OR lunch
$ mka bacon
NOTE: Some ROMs may use their own bacon command, read their manifest as they
will usually outline this.
Others may not use mka, use make -j$( nproc --all )
If you get an error here, make sure that you have downloaded all of the
proper vendor files from your ROM's repository.
Once you tell it mka bacon, the computer will start building. You
will know that it is done when you see a message saying make completed and
telling you where your flashable zip is located.
Whenever you build again, make sure you run a clean build every time by placing
this command in between the other two:
$ make clobber
That's it! You successfully compiled a ROM from scratch :) By doing this, you
control when you get the new features, which means as soon as they are available
on Github. After this, you may even want to start contributing, one of the
greatest things about Android and open source software in general.
#################
# Jack issues #
#################
For those of you who are having jack issues (like saying you ran out of memory),
follow these steps.
Type this into your terminal, substituting the # with how many GBs of RAM
you have:
$ export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx#g"
Then go into the root of the source folder and type the following:
$ ./prebuilts/sdk/tools/jack-admin kill-server
$ ./prebuilts/sdk/tools/jack-admin start-server
This will restart the jack server to reflect your new heap limit.
#############
# Support #
#############
If you run into any issues while building, you can use the following chat room for assistance
(be sure to read the rules): https://t.me/AndroidBuildersHelp
This chat is only for build errors or to get the build to compile.
After you have successfully built the ROM, for any required assistance, use this chat
https://t.me/AndroidBringup
####################
# Special thanks #
####################
@Mazda-- for spearheading the Dirty Unicorns project, his dedication to
open source, and helping me out at random points during compilation.
@BeansTown106 for the various advice and guidance he has provided plus
his contributions to the open source community through the Pure Nexus Project.
@akhilnarang for his build environment scripts.
@npjohnson for the Ubuntu 16.04 Java 7 instructions.
================================================
FILE: guides/proper_bug_reporting.txt
================================================
###############################
# #
# PROPER AOSP BUG REPORTING #
# #
###############################
Many times when using a custom ROM or kernel, you may experience an issue. The
developer may want something called a logcat or dmesg to look into this but you
may not know how to do that. There are a couple of ways to do so and that is
what I am going to explain now. This is valid for themers, ROM developers, and
kernel developers.
A logcat is useful for debugging crashes or other weird behaviors with apps or
themes. A radio logcat details what's going on in the phone's actual phone
functionality. It tells you any errors that occured while trying to call.
A dmesg is a kernel log, detailing what each subsystem is doing.
A ramoops is the previous dmesg, which will detail why a phone force restarted.
A ramoops is also known as last-kmsg or pstore, and can be retrieved from a
custom recovery as well as from a booted device.
###################
# 1. USING AN APP #
###################
1. Getting a logcat:
a. Download a logcat app from the Play Store (I will be using Matlog for
the rest of this tutorial).
b. Open the app and grant it root permissions (if you are not rooted and
do not want to be, you will need to use ADB below).
c. Clear the buffer but clicking the three dot menu and hitting clear.
d. Click on the three dot menu, choose Settings, then Log Buffer(s).
e. Tick either radio, main or both depending on the type of bug.
f. Click on the three dot menu, choose File, then Record.
g. Duplicate your crash/issue.
h. Go back into Matlog and hit the stop button in the lower righthand corner.
i. Send the generated file to your developer/themer following the etiquette
below.
2. Getting a dmesg:
a. Either download a dmesg app and follow similar steps as above OR download
a terminal emulator and continue on.
b. Open your terminal emulator and type su to enter as the root user.
c. Type dmesg > /sdcard/test.log
d. Send the generated file (located in the head folder of your internal
storage partition) to your developer, following the etiquette below.
3(a). Getting a ramoops via system:
a. Open a file manager and navigate to /sys/fs/pstore and copy the file
named console-ramoops or console-ramoops1 to your sdcard folder.
b. Send that file to your kernel developer following the etiquette below.
3(b). Getting a ramoops via recovery:
a. Ensure your device has TWRP installed from fastboot, search XDA for help
b. Immediately after the device reboots, force it to recovery by holding
volume buttons.
c. Click [Advanced] and then [File Manager]. Navigate to /sys/fs/pstore
and copy the file named console-ramoops or console-ramoops1 to /sdcard.
Send that file to your kernel developer or whoever caused the bug
following the etiquette below
################
# 2. USING ADB #
################
1. Download the latest tools from Google:
https://dl.google.com/android/repository/platform-tools-latest-linux.zip
https://dl.google.com/android/repository/platform-tools-latest-darwin.zip
https://dl.google.com/android/repository/platform-tools-latest-windows.zip
2. Extract those to a folder and move into that folder:
$ cd <folder_location>
3. Plug in your device and accept the debugging prompt (turn on ADB in
Settings > Developer Options if you don't see it).
4. Verify your device is recognized.
$ adb devices or $ ./adb devices
5. Clear the logcat buffer.
$ adb logcat -c or $ ./adb logcat -c
6. Take your log:
Logcat: $ adb logcat -d > test.log or $ ./adb logcat -d > test.log
dmesg: $ adb shell dmesg > test.log or $ ./adb shell dmesg > test.log
7. Give that log to the appropriate party with a proper report, following the
etiquette below.
##################################
# PROPER BUG REPORTING ETIQUETTE #
##################################
1. First and foremost, understand that for the vast majority of people, this is
a hobby, not a job. It may take some time for your issue to be resolved.
Being a jerk or bossy is likely to get you banned or at the least have your
issue dismissed.
2. Write in clear, concise manner what the issue is with steps to reproduce
Bad: My phone is broken, help!
Good: Whenever I open YouTube after a clean flash, it force closes.
3. Explain what you have done. A developer should not have to ask what has
already been attempted.
4. Provide any scenarios/ROMs where it did work (was it working in a previous
update, etc.)
5. If you are technically inclined, provide commits that are either the issue
or will resolve the issue. Developers love having a solution presented for
them.
================================================
FILE: scripts/bldgcc
================================================
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Copyright (C) 2021 Nathan Chancellor
#
# The shebang is just for shellcheck auditing; this script needs to be sourced and
# called by the function name otherwise it literally does nothing. It works in
# bash and zsh.
#
# Builds GCC and binutils for exclusively building kernels
#
# This can be downloaded and sourced without any of the other scripts in this repo.
#
# $ curl -LSsO https://github.com/nathanchance/android-tools/raw/main/scripts/bldgcc
#
# Open the bldgcc file to make sure it matches this one.
#
# $ source bldgcc
#
# Usage:
# $ bldgcc arm arm64
#
# By default, the script will contain everything to a 'gcc' folder in ${PWD}.
# To change where that gcc folder is, either 'export GCC_TC_FOLDER=<value>' or
# 'GCC_TC_FOLDER=<value> bldgcc'.
#
# By default, the GCC and binutils versions will be the latest available.
# To change the versions, either 'export GCC_VERSION=<value> BINUTILS_VERSION=<value>'
# or 'GCC_VERSION=<value> BINUTILS_VERSION=<value> bldgcc'.
#
# The possible versions can be found here:
# https://mirrors.kernel.org/gnu/gcc/
# https://mirrors.kernel.org/gnu/binutils/
#
# This script is designed to build release versions of this software, not development
# versions. If you want to do that, it's not hard to modify this script to do that or
# use https://github.com/USBhost/build-tools-gcc
function bldgcc() { (
BLD_OPTS=(--toolchain)
TARGETS=()
# Get parameters
[[ ${#} -eq 0 ]] && {
echo "ERROR: This function needs targets!" >&2
echo "Some of the possible options (can provide more than one):" >&2
echo " arm, arm64, m68k, mips, mipsel, powerpc, powerpc64, powerpc64le, riscv64, s390x, x86_64" >&2
exit 1
}
while ((${#})); do
case ${1} in
--binutils | --gcc | --toolchain) BLD_OPTS=("${1}") ;;
all) TARGETS=(arm arm64 m68k mips mipsel powerpc powerpc64 powerpc64le riscv64 s390x x86_64) ;;
*) TARGETS+=("${1}") ;;
esac
shift
done
# Create folders
GCC_BLD=${GCC_TC_FOLDER:=${PWD}/gcc}/build
mkdir -p "${GCC_TC_FOLDER}"
[[ ! -d ${GCC_BLD} ]] && git -C "${GCC_TC_FOLDER}" clone https://github.com/nathanchance/buildall build
cd "${GCC_BLD}" || {
echo "buildall clone failed!" >&2
exit 1
}
# Download GCC
[[ -z ${GCC_VERSION} ]] && GCC_VERSION=11.2.0
GCC_SOURCE=gcc-${GCC_VERSION}
[[ ! -d ${GCC_SOURCE} ]] && curl -LSs https://mirrors.kernel.org/gnu/gcc/${GCC_SOURCE}/${GCC_SOURCE}.tar.xz | tar -xJf -
# Download binutils
[[ -z ${BINUTILS_VERSION} ]] && BINUTILS_VERSION=2.37
BINUTILS_SOURCE=binutils-${BINUTILS_VERSION}
[[ ! -d ${BINUTILS_SOURCE} ]] && curl -LSs https://mirrors.kernel.org/gnu/binutils/${BINUTILS_SOURCE}.tar.xz | tar -xJf -
# Create timert
[[ ! -f timert ]] && make -j"$(nproc)"
# Create config
cat <<EOF >config
BINUTILS_SRC=${PWD}/${BINUTILS_SOURCE}
CHECKING=release
ECHO=/bin/echo
GCC_SRC=${PWD}/${GCC_SOURCE}
MAKEOPTS=-j$(nproc)
PREFIX=${PREFIX:-${GCC_TC_FOLDER}/${GCC_VERSION}}
EOF
# Build the toolchains
for TARGET in "${TARGETS[@]}"; do
# Clean up previous artifacts, can cause a false failure
rm -rf "${TARGET}"
PATH=${PATH%%:\/mnt\/c\/*} ./build "${BLD_OPTS[@]}" "${TARGET}"
done
); }
================================================
FILE: scripts/haste
================================================
#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
#
# Copyright (C) 2021 Nathan Chancellor
#
# Function to upload to a haste-server (points to https://paste.myself5.de/ by default)
#
# This can be downloaded and sourced without any of the other scripts in this repo.
#
# $ curl -LSsO https://github.com/nathanchance/android-tools/raw/main/scripts/haste
#
# Open the haste file to make sure it matches this one.
#
# $ source haste
#
# Usage:
# $ haste <file>
# $ command |& haste
function haste() { (
for BINARY in curl jq; do
command -v ${BINARY} &>/dev/null || {
echo "ERROR: ${BINARY} is not installed" >&2
exit 1
}
done
[[ -z ${HASTE_URL} ]] && HASTE_URL=https://paste.myself5.de
RESULT=$(curl -sf --data-binary @"${1:--}" "${HASTE_URL}"/documents) || {
echo "ERROR: failed to post document, ca-certificates might need to be installed" >&2
exit 1
}
echo "${HASTE_URL}/raw/$(jq -r .key <<<"${RESULT}")"
); }
gitextract_i2v0kt5d/
├── README.md
├── guides/
│ ├── building_aosp.txt
│ └── proper_bug_reporting.txt
└── scripts/
├── bldgcc
└── haste
Condensed preview — 5 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (19K chars).
[
{
"path": "README.md",
"chars": 364,
"preview": "# Android Tools\n\nThis repository contains public guides and scripts tailored for custom Android Development. The scripts"
},
{
"path": "guides/building_aosp.txt",
"chars": 8253,
"preview": "###########################\n# #\n# MAY 31, 2021 UPDATE #\n# #\n########"
},
{
"path": "guides/proper_bug_reporting.txt",
"chars": 4855,
"preview": "\n###############################\n# #\n# PROPER AOSP BUG REPORTING #\n# "
},
{
"path": "scripts/bldgcc",
"chars": 3360,
"preview": "#!/usr/bin/env bash\n# SPDX-License-Identifier: MIT\n#\n# Copyright (C) 2021 Nathan Chancellor\n#\n# The shebang is just for "
},
{
"path": "scripts/haste",
"chars": 991,
"preview": "#!/usr/bin/env bash\n# SPDX-License-Identifier: MIT\n#\n# Copyright (C) 2021 Nathan Chancellor\n#\n# Function to upload to a "
}
]
About this extraction
This page contains the full source code of the nathanchance/Android-Tools GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 5 files (17.4 KB), approximately 4.6k tokens. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.