[Android Software/Hacking General [Developers Only]] droidvoider:
Now tested up to downloading AOSP and make toolbox you should be all set

Please give thanks to this thread: https://xdaforums.com/newreply.php?do=newreply&p=43622764

Warning: I hacked my way through this stuff a few weeks ago I am not an expert!

How to compile Android Open Source Code modules​

I don't compile C code on Windows machines I have no idea about that.

Notice

This guide is a quick and dirty how to make a module. It will not cover finalizing setting up the source codes for your device. It is only my goal to enable you to compile binaries such as grep, toolbox, dumpstate, dalvikvm, jack and etc.

===>] Setup Ubuntu 64bit [<===​

Unplug that Windows drive, plug in a fresh hard drive and install Ubuntu latest/greatest. Ignore the recommendation to downgrade gnu make!, for now.

Open a terminal and issue these commands (warning ppa repository for OpenJDK 7 is said to have a security issue?, isn't being updated?.. whatevs it works)

sudo apt-get update
sudo apt-get upgrade
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get install openjdk-7-jdk
sudo apt-get install openjdk-8-jdk
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
sudo apt-get install git ccache automake lzop bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 g++-multilib python-networkx libxml2-utils bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev squashfs-tools pngcrush schedtool dpkg-dev liblz4-tool make optipng

(choose Java 1.7 in the following way)

sudo update-alternatives --config java

(let me know if I missed anything please)

"Tried the Android SDK only it is missing too many things we need as a developer"

===>] Setup Android Studio SDK & NDK [<===​

Installation Paths:

*** I install to /home/username/Android and /home/username/Android/Sdk and /home/username/Android/Sdk/ndk-bundle ***

NOTE: from here forward username will == droidvoider

Note: Android Studio IDE isn't necessary only the SDK & NDK are needed to compile AOSP.

Install Android Studio Proper: (don't worry about setting up paths we will cover that, just install it)

https://developer.android.com/studio/install.html

or

SDK Only:

Typically we install these things manually by creating the directory then just unzipping the files there.

https://developer.android.com/studio/index.html#linux-bundle (scroll down for sdk only)

mkdir /home/droidvoider/Android
mkdir /home/droidvoider/Android/Sdk

(then unzip the sdk zip to that directory. I recommend the file explorer copy/paste right click uncompress and done.)

https://dl.google.com/android/repository/tools_r25.2.3-linux.zip

Install NDK through the SDK Manger:

(from terminal 'studio.sh' and then configure, and then sdk manger --- if this is hard to figure out tell me I will elaborate)

or

Manually Install Native Development Kit -- 'c programming support'

Download the Native Development Kit from Google: https://developer.android.com/ndk/downloads/index.html

mkdir /home/droidvoider/Android/Sdk/ndk-bundle

Then just unzip the ndk files into the directory we created above.

===>] Setup your toolchain [<===​

** This example is arm64-v8a aarch64 **

1. Navigate to /home/droidvoider/Android/Sdk/ndk-bundle/build/tools and then open a terminal "right click open area"

2. mkdir /home/droidvoider/toolchains

3. ./make_standalone_toolchain.py --arch arm64 --api 23 --stl=libc++ --install-dir /home/mm/toolchains/aarch64-linux-android-4.9

4. cd /home/droidvoider

5. gedit .bashrc and morph this in at the bottom.. (AND edit or replace the existing PATH variable)

DON'T just PASTE IN *my* $PATH export!! I included my entire path statements to show you.

export PATH=$PATH:/usr/local/android-studio/bin:/home/droidvoider/Android/Sdk/platform-tools:/home/droidvoider/Android/Sdk/ndk-bundle:/home/droidvoider/Android/Sdk/tools

I feel this is human readable, for example change Android_Build_Out to be on your desktop instead if you want.

export PATH=$PATH:/home/droidvoider/toolchains/aarch64-linux-android-4.9
export NDK=/home/droidvoider/Android/Sdk/ndk-bundle
export SYSROOT=$NDK/platforms/android-23/arch-arm64
export TARGET=aarch64-linux-android
export HOST=$TARGET
export BUILD=x86_64-linux
export ANDROID_NDK_BIN=/home/droidvoider/toolchains/aarch64-linux-android-4.9/bin
export CC=$ANDROID_NDK_BIN/aarch64-linux-android-gcc-4.9
export CPP=$ANDROID_NDK_BIN/aarch64-linux-android-g++
export AR=$ANDROID_NDK_BIN/aarch64-linux-android-ar
export OUT_DIR_COMMON_BASE=/home/droidvoider/Android_Build_Out

Note: You might want to setup an alternate toolchain also but this is all of the puzzle pieces.

===>] Google's version of this How To -- Just for reference [<===​

https://source.android.com/source/requirements.html

https://source.android.com/source/initializing.html

===>] Install the repo tool [<===​

https://source.android.com/source/downloading.html

(don't type repo init or repo sync --- I will be taking back over from there on the next page)

Added Repair Notes -- Not part of the install!

Have you accidentally installed or removed something you shouldn't have? (welcome to development, here try this before reinstall)

sudo apt-get clean

sudo apt-get update

sudo apt-get install -f

sudo dpkg -a --configure

sudo apt-get dist-upgrade

sudo apt-get install -f

sudo dpkg -a --configure