Related
So you want to build CyanogenMod and don't know where to start?
I wanted to make a step-by-step guide for installing and configuring everything necessary for building CM9 in a virtual machine (VM) on a Windows machine. There's a scattered information in the forums on most of this, but I wanted to bring it together and share what worked best for me for any newbies who want to try to get their feet wet with AOSP development, or who would just like to be able to have their own up to date builds from source.
Huge thanks go out to dmeadows013 and antp121. It was their guides I started with when doing this myself, and without them, I don't think I would have even known where to begin. Their guides are at http://forum.xda-developers.com/showthread.php?t=1810297 and http://forum.xda-developers.com/showpost.php?p=31530111&postcount=12
This guide is designed to allow people with no Linux or development experience to get up and running as quickly as possible. Though no prior knowledge should be required, I highly recommend that you pay attention to what you are doing, and research or ask about anything you have questions about so that you'll understand the process. I've divided this into multiple parts to make it easier to do in stages.
What you need:
1) A Windows computer, preferably with a CPU that supports hardware virtualization. Most relatively modern processors do, so if you've bought your computer in the last 4 or 5 years, it's probably fine. Without this, you won't be able to run 64-bit or multiple processor VM's. Your Windows OS doesn't have to be 64-bit, your CPU just needs to support hardware virtualization. I won't say that this will not work on a 32-bit VM, but I've never tried it, so I can't support it if it doesn't. If you want to try, just replace all of the references to 64-bit in this guide with 32-bit.
2) Plenty of memory. I recommend at least 4GB on the host computer. You can make it work on less, but more is better.
3) At least 60GB of free hard drive space during the install, at least 50GB of which will be used permanently.
4) Plenty of time on your hands. You don't want to be rushed while you're doing this the first time.
Preliminaries:
1) Go to https://www.virtualbox.org/wiki/Downloads and download the latest version of VirtualBox for Windows hosts. The current version as of this writing is 4.2.
2) From the same website, download the latest version of the Virtual Box Extension Pack.
3) Go to http://www.ubuntu.com/download/desktop and download the 64-bit version of Ubuntu Desktop 12.04.1 LTS. This version will be supported for at least two years and will provide a stable OS base for at least that length of time.
Install and configure VirtualBox:
1) Run the VirtualBox installer executable you downloaded in the preliminaries section. Choose the default options at every prompt.
2) During the installation, the software will ask you for permission to install drivers. Choose install when it asks.
3) When the installation is complete, uncheck the box to start the application, then click Finish.
4) Run the VirtualBox Extension Pack installer that you downloaded in the preliminaries, and click Install and Agree.
5) From the VirtualBox Manager, click New
6) Name your machine whatever you wish (Android Build Box, for example), select Linux as the type, and Ubuntu (64-bit) as the version. Click Next
7) Give the machine as much memory as you can spare and click Next. I've found myself to need at least 1536MB (1.5GB) as a minimum to build with. More memory will result in a faster build time. If you intend to give the machine more than one processor, you need to give it more memory as well.
8) On the Hard drive prompt, click Create
9) Choose VDI and click Next
10) Choose Dynamically allocated and click Next
11) Give the drive at least 50GB of space and click Create. As always, more is better. 50GB will give you enough room to work on a single copy of CM9 with a little breathing room. You need more if you want to work on multiple copies.
12) Choose your VM and click Settings
13) Click the Advanced tab in General settings. Set Shared Clipboard to Bidirectional. This will allow you to copy and paste between the virtual machine and your Windows host.
14) If you wish to give your VM access to more than one processor, click on System, then choose the Processor tab. Select the number of processors you wish your VM to use.
15) Click OK. Your VM is now configured.
Install Ubuntu 12.04.1:
1) In the VirtualBox Manager, choose your VM and click Settings.
2) Click Storage.
3) Click Empty, underneath the IDE Controller entry.
4) On the far right, under Attributes, click the small CD icon and click "Choose a virtual CD/DVD disk file..."
5) Choose the file ubuntu-12.04.1-desktop-amd64.iso that you downloaded earlier
6) Click OK
7) Make sure your VM is selected, and click Start.
8) As it boots, confirm the messages that appear, click "Do not show this message again" if desired.
9) After a few minutes, the VM will boot to a selection screen. Choose Install Ubuntu.
10) Click Download updates while installing and Install this third party software. Click Continue.
11) Leave Erase disk and install Ubuntu checked, then click Continue. This will only erase the virtual drive.
12) Click Install Now.
13) Choose your time zone and click Continue.
14) Choose your keyboard layout and click Continue.
15) Set up your username, password, and a machine name. REMEMBER THIS PASSWORD. You will need it, even if you enable Log in automatically. Click Continue.
16) Now sit back and relax. The installation will take a while.
17) When installation is complete, click Restart Now
18) When prompted, press Enter
19) The VM will reboot into your new Ubuntu installation.
A note about your new VM installation of Ubuntu: This is just like any other computer and should be treated as such. It needs to be properly shut down to prevent disk corruption. To shut down the system, click the gear icon in the upper right and choose Shut down. You should also keep the system properly updated, because when it is running, it is just as accessible to the Internet as any other computer on your network, so keep the security updates installed as you are notified.
Update Ubuntu 12.04.1 and install Guest Additions:
1) Log into your system with the user you created during installation. Ignore any warnings you may get about new drivers being available. We will take care of that in a bit.
2) Click the top icon of the sidebar (Dash Home), type update, and click Update Manager.
3) Click Install Updates
4) When prompted, enter your user password.
5) When updating is complete, click Restart Now
6) After restart, log back in.
7) In the VM Window menu, click Devices, then click Install Guest Additions...
8) Click Run and enter your password when prompted.
9) After process completes, reboot by clicking the gear in the upper right corner, clicking Shut Down, and clicking Restart.
Configure your build environment
1) Log into your Ubutntu system, open Firefox from the sidebar and go to http://www.oracle.com/technetwork/java/javase/downloads/jdk6u35-downloads-1836443.html
2) Click agree and download jdk-6u35-linux-x64.bin
3) Click on Dash Home, type terminal, and open the Terminal app.
4) Right click on Terminal in the sidebar and select Lock to Launcher.
5) Retrieve the build tools:
Code:
sudo apt-get install git-core git gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool gcc-multilib g++-multilib pngcrush g++ gcc dpkg-dev
6) Unpack Java by typing the following commands in terminal:
Code:
chmod a+x ~/Downloads/jdk-6u35-linux-x64.bin
sudo mv ~/Downloads/jdk-6u35-linux-x64.bin /usr/lib
cd /usr/lib
sudo ./jdk-6u35-linux-x64.bin
7) Install Java by executing the following commands:
Code:
sudo mv jdk1.6.0_35/ jvm/
sudo rm jdk-6u35-linux-x64.bin
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_35/jre/bin/java 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_35/bin/javac 1
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_35/bin/jar 1
sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.6.0_35/bin/javadoc 1
8) Make Java 1.6 the default by typing the following commands individually, and selecing the jdk1.6.0_35 line in each (typically number 2):
Code:
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config jar
sudo update-alternatives --config javadoc
Create the build directories and retrieve the code:
1) Log into your Ubuntu system and open a terminal window
2) Create your build directories:
Code:
mkdir ~/android ~/android/bin ~/android/cm-10.1
3) Open your profile config:
Code:
gedit ~/.bashrc
4) Insert the following into the end of your profile:
Code:
ANDROID_JAVA_HOME=/usr/lib/jvm/jdk1.6.0_35
export ANDROID_JAVA_HOME
PATH=~/android/bin:$PATH
export PATH
5) To reload your profile, exit your terminal window and open a new one.
6) Download the repo binary:
Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/android/bin/repo
chmod a+x ~/android/bin/repo
7) Initialize and sync the repo (download the code). This will typically take a couple of hours the first time you run it:
Code:
cd ~/android/cm-10.1
repo init -u git://github.com/Chad0989/android.git -b cm-10.1
repo sync
8) Retrieve the prebuilts:
Code:
./vendor/cm/get-prebuilts
Build CM10.1
1) Now, all that's left is to build. If you want to get the latest code, run another repo sync (included here). It only retreives changes, so it should only take a few minutes from now on. Ignore warnings and let it build. As long as it doesn't crash, you're fine. It can take anywhere from an hour to half a day, depending on the resources you gave the VM:
Code:
cd ~/android/cm-10.1
repo sync
. build/envsetup.sh
make clobber
brunch vigor
2) Go get your freshly baked CM10.1 from ~/android/cm-10.1/out/target/product/vigor.
I hope this is useful for someone. This guide is the result of several days of learning on my part, and several hours of writing. If there is anything that doesn't work, let me know. I will probably be cleaning it up a bit in the near future, and I may add an FAQ and/or glossary if it appears that one is needed. I'll also attempt to keep it updated with the newest versions of the tools. Thanks for reading, and have fun building.
Special thanks to:
dmeadows013 and antp121 - For providing the guides that got me started. I couldn't have done any of this without you.
chad0989 - For AOSP on the Rezound.
IAmTheOneTheyCallNeo - For answering my stupid questions and inspiring me to get more involved
Snuzzo - For answering more stupid questions and giving more inspiration
synisterwolf - For being generally awesome and putting up with me in chat
puhleez - Who's environment issues inspired me to make this guide
Alternate instructions for setting up Debian:
After some discussions in the thread, I decided to switch to Debian for my build environment, because I hate Unity, and I've always liked Debian better anyway for a work system. I still recommend Ubuntu for most people, as it is the most noob friendly Linux build out there. If you're going to use Debian, or most of the other builds, you need a better understanding of the security model and an expectation that it's going to take a little more front end setup (that isn't covered here). However, if you want to use Debian, the instructions to configure the build environment are mostly the same. The only difference is the retrieval of the build tools. Debian names their 32-bit packages differently, so it changes to this:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev lib32ncurses5-dev x11proto-core-dev lib32libreadline6-dev libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos python-markdown libxml2-utils xsltproc lib32z1-dev schedtool gcc-multilib g++-multilib pngcrush
Alternate instructions for building PAC-man:
The guide will be the same until the point where you initialize the repo (Create the build directories and retrieve the code, step 7). Instead of those steps, do the following:
Code:
mkdir ~/android/pac
cd ~/android/pac
repo init -u git://github.com/PAC-man/android.git -b cm-10.1
repo sync
There is no need to retrieve the prebuilts or set up the environment for PAC. The build script will do everything. To build, just do this:
Code:
cd ~/android/pac
repo sync
make clobber
./build-pac.sh vigor
Since this is a multi-device repo, the initial build will take a little longer, because the script will retrieve the missing pieces for vigor, and replace some things that are little different for us than the standard, but the build itself should be around the same time as a stock CM10.1 build.
This is pretty sweet. Thanks for this. When im bored at work next week I def give this a go.
Ive been wanting to try this but I don't think my little dual core laptop is up to it lol. Thanks for the write up
Sent from my ADR6425LVW using Tapatalk 2
Thank you. Now I can refer people to this page. I have never done it in a virtual box.
This is awesome Shrike. It will help encourage people to get into building roms that wouldn't have otherwise run across it. Things like this help to continue the android hobby and lifestyle that so many of us enjoy.
If anyone here is interested in setting up a VPS on our server so they can build roms on a virtual build box even if they don't have a powerful computer, just let me know.
Thank you so much. Too many people bothering me on gtalk about this.
This is an awesome guide. Definitely need start getting invovled with developing for Android. It would be cool we could get a guide on how to do this with the linaro tool chain also.
Great work and thanks for contributing
awesome going to read this later. thanks for the guide.
Wow man. I can' t thank you enough for spending the time to put this together. I struggled with getting it to work and after many attempts just gave up. I'll definitely be trying again, maybe this afternoon.
Thanks again!!
Thank you for this. I am working through the procedure now. Other than the location of the jvm in the initial install everything is looking good (details will follow when I confirm it wasn't an ID10T error on my part).
---------- Post added at 04:16 PM ---------- Previous post was at 04:11 PM ----------
merashallan said:
Thank you for this. I am working through the procedure now. Other than the location of the jvm in the initial install everything is looking good (details will follow when I confirm it wasn't an ID10T error on my part).
Click to expand...
Click to collapse
I figured out the problem. If you install the Oracle java before you install all the additional packages there will not be a directory named /usr/lib/jvm as the openjdk has not yet been installed. This also means you have to repeat step 7 after step 8 since there are no alternatives to Oracle java before step 7.
I think if you perform step 8 before step 5 the procedure will work.
Anyways it's looking like a good guide so far as it's saving me lots of time figuring out what I need.
doing my repo sync right meow.
merashallan said:
Thank you for this. I am working through the procedure now. Other than the location of the jvm in the initial install everything is looking good (details will follow when I confirm it wasn't an ID10T error on my part).
---------- Post added at 04:16 PM ---------- Previous post was at 04:11 PM ----------
I figured out the problem. If you install the Oracle java before you install all the additional packages there will not be a directory named /usr/lib/jvm as the openjdk has not yet been installed. This also means you have to repeat step 7 after step 8 since there are no alternatives to Oracle java before step 7.
I think if you perform step 8 before step 5 the procedure will work.
Anyways it's looking like a good guide so far as it's saving me lots of time figuring out what I need.
Click to expand...
Click to collapse
Thanks for the feedback. I've incorporated it in the the document.
This is awesome. I've always wondered how to go about compiling and such, but didn't want to bug any of the developers. This is definitely a start into developing! Thank you
Deleted
When you repo sync, where is the data supposed to go? in the root of HOME or in ANDROID/CM9? Mine went into the root of HOME.
h4ckers said:
When you repo sync, where is the data supposed to go? in the root of HOME or in ANDROID/CM9? Mine went into the root of HOME.
Click to expand...
Click to collapse
It should go to ~/android/cm9. There was a typo in step 7 of the build directory setup. Sorry about that. Fixed now.
nice job man
shrike1978 said:
It should go to ~/android/cm9. There was a typo in step 7 of the build directory setup. Sorry about that. Fixed now.
Click to expand...
Click to collapse
I noticed that. I copied everything to where it needs to go. Did this command again to make sure I had all the changes:
Code:
cd ~/android/cm9
repo sync
Still went to the root of HOME. Strange. After building a test, I will see what else I can do to fix my issue. Thanks for the guide and by chance do you know where to pull AOKP and MIUI? I saw Dmeadows' git but didn't know what to pull.
h4ckers said:
I noticed that. I copied everything to where it needs to go. Did this command again to make sure I had all the changes:
Code:
cd ~/android/cm9
repo sync
Still went to the root of HOME. Strange. After building a test, I will see what else I can do to fix my issue. Thanks for the guide and by chance do you know where to pull AOKP and MIUI? I saw Dmeadows' git but didn't know what to pull.
Click to expand...
Click to collapse
I haven't tried to build either yet, so I haven't the foggiest where to start. TBH, I'm not a particularly big fan of either, so I've never really looked into it. However, the build environment should be sane to build them if you can figure out where to get them and what code you need to merge.
Hello everyone I'm new to android and have been trying to run Emscripten on it: I've ported over the necessary dependencies: Node, Python, Fastcomp/Clang via the NDK Toolchain and tested with the Android Emulator (from Android SDK) inside the the Android Terminal Emulator (from jackpal's github) but when I finally attempted to run Emscripten itself as so:
Code:
cd /data/data/jackpal.androidterm/shared_prefs
bin/python2 emscripten-1.22.1/emcc -v
I ran into some rather vague error messages:
Code:
[2] + Stopped (signal) bin/python emscripten-1.22.1/emcc -v
[1] - Segmentation fault bin/python emscripten-1.22.1/emcc -v
Does anyone have any ideas on this? I there a way I can get better debugging info to help find the problem?
I think I figured out the problem. Those error seem to come from python. Particularly python seems to be crashing. Trying the python console doing a simple:
Code:
import shutil
will crash the interpreter. Since discovering this I've found many other things that will crash python in my setup. So I guess it wasn't such a good port after all.
I ran some test in the python interpreter as this is what I go so far:
These modules are fine:
Code:
os, platform, re, pprint, atexit, subprocess, sys, time, string, struct
These modules will crash python:
Code:
optparse, logging, urlparse, SocketServer, cgi shutil, tempfile, shlex
These modules will spit out error messages but not crash python:
Code:
BaseHTTPServer, SimpleHTTPServer, socket,
Don't really, no what is cause this yet.
After trying to build python several different ways and not getting those modules to work I broke down and decided to try out Python4Android. And it works. After following their guide on getting it to work in the shell, I test the modules and they were fine. After that I pushed my builds of fastcomp(llvm/clang) and node.js and the Emscripten python scripts ot Py4A's files location and then tried to run emcc (emscripten's compiler).
The scripts needed a little (very little) tweeking to get them to work but they worked. And now I'm going to try and copy Py4A's files to Android Terminal Emulators' location. If that works to my satisfaction I'll try to get these to work with VimTouch.
Hello friends! I post this on the off to pic because I can't really find a fitting sub-forum. If you know a better place I can post this thread, please let me know.
I want ruby and Ruby gems to run on my android device (galaxy S4 GT-I9515, not that it matters). I know android is Linux based so there shouldn't be a problem doing this.
Basically, I don't want to use Ruby for development, I just need to use some of it's applications (gems).
I tried ruboto core and ruboto IRB, but couldn't install a gem.
In general, my android won't read "apt-get" command in terminal. I don't know why.
If anyone could help me to run some Ruby gems on my device, I would really appreciate it. Thanks for people who answer!
Android is a Linux kernel, however it is not a full Linux like Debian or Ubuntu.
Android doesn't have a package manager by default (unless with Google Play or other app markets). It doesn't have apt-get.
However, I can say that there's a terminal called Termux in Google Play or F-Droid.
It does have apt and it doesn't require root.
I found Ruby in the apt repos of Termux though.
Code:
$ apt list | grep ruby
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
ruby/stable 2.3.3 arm
ruby-dev/stable 2.3.3 arm
ruby-ri/stable 2.3.3 all
weechat-ruby-plugin/stable 1.6-1 arm
TheKindleMCPEGuy said:
Android is a Linux kernel, however it is not a full Linux like Debian or Ubuntu.
Android doesn't have a package manager by default (unless with Google Play or other app markets). It doesn't have apt-get.
However, I can say that there's a terminal called Termux in Google Play or F-Droid.
It does have apt and it doesn't require root.
I found Ruby in the apt repos of Termux though.
Code:
$ apt list | grep ruby
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
ruby/stable 2.3.3 arm
ruby-dev/stable 2.3.3 arm
ruby-ri/stable 2.3.3 all
weechat-ruby-plugin/stable 1.6-1 arm
Click to expand...
Click to collapse
First of all thanks for the reply!
So, in order to use ruby on android all I have to do is use a more linux-like terminal, and use the command "$ apt list | grep ruby", am I right?
Will I have access to apt-get and commands like that with the new terminal?
FurySh0ck said:
Android is a Linux kernel, however it is not a full Linux like Debian or Ubuntu.
Android doesn't have a package manager by default (unless with Google Play or other app markets). It doesn't have apt-get.
However, I can say that there's a terminal called Termux in Google Play or F-Droid.
It does have apt and it doesn't require root.
I found Ruby in the apt repos of Termux though.
First of all thanks for the reply!
So, in order to use ruby on android all I have to do is use a more linux-like terminal, and use the command "$ apt list | grep ruby", am I right?
Will I have access to apt-get and commands like that with the new terminal?
Click to expand...
Click to collapse
Termux is not really more Linux like, it's still using the same kernel. It downloads a core (other applications, etc) to /data folder. That's how it works.
You will have access to apt in the new terminal. However, there is not much packages in the repo as your Android device is ARM and the packages have to be built into a package file. If you'd like the full experience, consider using a KVM or Xen VPS which run full on distributions (Debian, Ubuntu, etc). They also have more packages over there.
Now to install Ruby, you wouldn't apt list. What you would do in Termux:
Code:
apt install ruby
would install Ruby and you would be able to use it and install gems.
I installed Ruby with that command and confirmed it works:
Code:
$ apt install ruby
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
ruby
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3587 kB of archives.
After this operation, 18.3 MB of additional disk space will be used.
Get:1 [url]http://termux.net[/url] stable/main arm ruby arm 2.3.3 [3587 kB]
Fetched 3587 kB in 1s (2878 kB/s)
Selecting previously unselected package ruby.
(Reading database ... 2137 files and directories currently installed.)
Preparing to unpack .../archives/ruby_2.3.3_arm.deb ...
Unpacking ruby (2.3.3) ...
Processing triggers for man (1.13.4-3) ...
Setting up ruby (2.3.3) ...
When I ran the
Code:
gem
command I got this:
Code:
$ gem
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
Usage:
gem -h/--help
gem -v/--version
gem command [arguments...] [options...]
Examples:
gem install rake
gem list --local
gem build package.gemspec
gem help install
Further help:
gem help commands list all 'gem' commands
gem help examples show some examples of usage
gem help gem_dependencies gem dependencies file guide
gem help platforms gem platforms guide
gem help <COMMAND> show help on COMMAND
(e.g. 'gem help install')
gem server present a web page at
[url]http://localhost:8808/[/url]
with info about installed gems
Further information:
[url]http://guides.rubygems.org[/url]
Enjoy!
TheKindleMCPEGuy said:
Termux is not really more Linux like, it's still using the same kernel. It downloads a core (other applications, etc) to /data folder. That's how it works.
You will have access to apt in the new terminal. However, there is not much packages in the repo as your Android device is ARM and the packages have to be built into a package file. If you'd like the full experience, consider using a KVM or Xen VPS which run full on distributions (Debian, Ubuntu, etc). They also have more packages over there.
Now to install Ruby, you wouldn't apt list. What you would do in Termux:
Code:
apt install ruby
would install Ruby and you would be able to use it and install gems.
I installed Ruby with that command and confirmed it works:
Code:
$ apt install ruby
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
ruby
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 3587 kB of archives.
After this operation, 18.3 MB of additional disk space will be used.
Get:1 [url]http://termux.net[/url] stable/main arm ruby arm 2.3.3 [3587 kB]
Fetched 3587 kB in 1s (2878 kB/s)
Selecting previously unselected package ruby.
(Reading database ... 2137 files and directories currently installed.)
Preparing to unpack .../archives/ruby_2.3.3_arm.deb ...
Unpacking ruby (2.3.3) ...
Processing triggers for man (1.13.4-3) ...
Setting up ruby (2.3.3) ...
When I ran the
Code:
gem
command I got this:
Code:
$ gem
RubyGems is a sophisticated package manager for Ruby. This is a
basic help message containing pointers to more information.
Usage:
gem -h/--help
gem -v/--version
gem command [arguments...] [options...]
Examples:
gem install rake
gem list --local
gem build package.gemspec
gem help install
Further help:
gem help commands list all 'gem' commands
gem help examples show some examples of usage
gem help gem_dependencies gem dependencies file guide
gem help platforms gem platforms guide
gem help <COMMAND> show help on COMMAND
(e.g. 'gem help install')
gem server present a web page at
[url]http://localhost:8808/[/url]
with info about installed gems
Further information:
[url]http://guides.rubygems.org[/url]
Enjoy!
Click to expand...
Click to collapse
Awesome! It worked well and neat. +1 For your Thanks-o'-meter.
Now I have some questions about termux, if you could answer:
1) Where does it save all the files? I used
Code:
apt update
and I am going to download packages from now on. I think I should know where it goes / how can I change that save directory.
2) When I tried using root permissions (you know, my device is rooted so I used
Code:
su
in order to gain access) I couldn't use apt commands anymore. I think some of my ruby gems will require root permissions, so I would like further explanation about it (only if you could of course )
FurySh0ck said:
Termux is not really more Linux like, it's still using the same kernel. It downloads a core (other applications, etc) to /data folder. That's how it works.
You will have access to apt in the new terminal. However, there is not much packages in the repo as your Android device is ARM and the packages have to be built into a package file. If you'd like the full experience, consider using a KVM or Xen VPS which run full on distributions (Debian, Ubuntu, etc). They also have more packages over there.
Now to install Ruby, you wouldn't apt list. What you would do in Termux:
would install Ruby and you would be able to use it and install gems.
I installed Ruby with that command and confirmed it works:
When I ran the command I got this:
Awesome! It worked well and neat. +1 For your Thanks-o'-meter.
Now I have some questions about termux, if you could answer:
1) Where does it save all the files? I used and I am going to download packages from now on. I think I should know where it goes / how can I change that save directory.
2) When I tried using root permissions (you know, my device is rooted so I used in order to gain access) I couldn't use apt commands anymore. I think some of my ruby gems will require root permissions, so I would like further explanation about it (only if you could of course )
Click to expand...
Click to collapse
1. It saves inside app data, specific folder is /data/data/com.termux/files/usr/var/cache/apt
2. I don't think su works in Termux really, however my root doesn't work right now so I can't really say a definite answer.
TheKindleMCPEGuy said:
1. It saves inside app data, specific folder is /data/data/com.termux/files/usr/var/cache/apt
2. I don't think su works in Termux really, however my root doesn't work right now so I can't really say a definite answer.
Click to expand...
Click to collapse
That's all I had to ask in this thread.
Thanks!
So, I have been an Android developer since 2009 (HTC dream), and have been actively "consuming" XDA, custom ROMs and other tweaks. Surprisingly, never tried to build my own ROM from scratch.
Recently, something made me want to build the ROM, so that I can make some changes to the way SystemUI behaves (specifically putting some app shortcuts to my Pixel phone(s), like camera etc. which are now removed in Android 10). So, after a week's struggle I got to where I wanted to reach. (90% time spent in getting the first successful flash. 1% feature development. 9% feature polishing).
Here is my guide to all beginners. (It is pretty simple, if you know the steps).
System setup
I have always been a Windows user (and I love my Surface(s)), but you cannot build Android on Windows machines (as clearly called out in source.android.com). I still tried to install Ubuntu shell from Microsoft store, and build (Spoiler alert: Does not work).
Next is Mac. Android can be built in Mac, I got it build in Mac. But, it is not easy. Especially with setting up the environment, having the right version of MacOS (doesn't work on Catalina yet). And also, challenges with filesystem format (Android building only works on case sensitive file system, so you have to create such a partition). Android building needs at least 160GB of disk space (so unless you are super rich and have 512GB+ Macbook with top specs, it is going to be hard).
My choice machine hence became, my two desktops (i7 4 core, 16GB, 1TB SSD, Ubuntu 18.04 and Xeon 12 core, 32GB, 512GB disk, with Ubuntu 18.04).
There is a reason why I specifically talk about these two machines. To build Android fast (cold clean build in less than 4 hours), you need
Fast processors, and more cores
Lots of RAM
A SSD disk (with 200GB space)
If you are missing any of the above 3, you will build times will go up. I have found for hot build, both machines did a decent job (2-3 mins if you are working on single module), but SSD was more important than cores, and RAM.
Setting up your Ubuntu machine. {ETA 30 mins}
Android has official (and clearly laid out) steps here.
But for Ubuntu these are pretty much the steps.
Code:
$sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev libgl1-mesa-dev libxml2-utils xsltproc unzip
And the guide doesn't mention this, but you need Python2.7, so get this.
Code:
# refreshing the repositories
sudo apt update
# its wise to keep the system up to date!
# you can skip the following line if you not
# want to update all your software
sudo apt upgrade
# installing python 2.7 and pip for it
sudo apt install python2.7 python-pip
# installing python-pip for 3.6
sudo apt install python3-pip
Also install adb.
Code:
sudo apt install android-tools-adb android-tools-fastboot
If you have come till here, you're ready to build for different devices.
Getting the code ready to build {ETA 5 hours - 1 day}
Most of this is also mentioned in the AOSP official website, but some stuff are tricky, I will try to highlight those steps here.
We are going to build the ROM for Pixel 3 (Android 10 - QP1A.191105.003 )
Download and explode the code {ETA 2-3 hours, depending on internet speed}
Here we are talking about downloading at least 20GB of code (text heavy content) over the internet. Going to be excruciatingly slow.
Also, we will be downloading code for specific device model, so if you want to do it for a newer model, you will have to go through the grind again.
Although, technically it might be possible to have the same folder contain code for multiple devices, it is too risky IMO, something goes wrong, you lose everything.
Recommended folder structure would be
aosp --> device 1
aosp --> device 2
......
aosp --> device n
Click to expand...
Click to collapse
With each folder containing over 150GB of contents (after downloading, building etc), so in practical sense, n could be only 3-4 at max.
Setting up repo.
Repo is a tool that Google uses to checkout and manage the AOSP code in your local machine. Once you download the codebase, you can use the command to resync, update, code base.
Code:
mkdir ~/bin
PATH=~/bin:$PATH
You should persist this folder in your PATH variable all the times.
Code:
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
This sets up repo in your machine.
One final step before you actually start the long download, setup your git details.
Code:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Now download the code. Like I previously suggested I would do this.
Code:
mkdir ~/aosp
cd ~/aosp
mkdir pixel3
cd pixel3
Now, let's start getting the code home.
Code:
repo init -u https://android.googlesource.com/platform/manifest -b android-10.0.0_r10 --depth=1
Here we have done a bunch of things.
We have chosen a particular Android build tag to download (branch). You can follow the link to choose which branch you want to checkout, based on your test phone and Android version you want to build.
We have asked to only download the latest version of the branch and not all of the branch (--depth), this considerably reduces our download time.
Now that we have decided what to download, let's download the code with this command.
Code:
repo sync -qc -j4
This command is going to take a while to download over 20GB of code. In the meanwhile, let's see what we did here.
-q Asks the download to be silent (which means it will show just overall progress)
-c Makes sure we are only downloading current branch
-j[x] This the tricky one. Let's talk about this.
With -j we are asking repo to spawn multiple downloads (parallelly), to speed up the process. We will see this flag going forward in other places also. We should keep the value of x to number of cores we have in our machine. To find how many cores you have run
Code:
nproc --all
. Note that I have had situations where I put a very high value for n (higher than my cores as well), and eventually ran my JVM out of RAM to run the command (in parallel). So, the trade off here is to restrict it to the core number.
***Key step: Download radio drivers.***
Most tutorials miss this or mention it very subtly. But, without this step the ROM you flash won't boot to the home screen (you will be in the boot loop).
Go to the driver binaries page, and download the right zip files for the Android build version (android-10.0.0_r10) and device (Pixel 3) you chose earlier in the repo command.
You will be downloading two zip files (one vendor image zip and one radio drivers zip), both zips will have on shell script file each (.sh), just put those two files in your repo folder (~aosp/pixel3) and run the scripts. It will download the required proprietary files (after asking you to accept the terms). Do not miss this step.. I lost 3 days trying to find the reason for my ROM not booting up, this was it.
Let's build our code
Now things are more definitive.
Code:
source build/envsetup.sh
This command basically sets up your environment, adding necessary commands to path etc.
Code:
lunch aosp_blueline-userdebug
You can read more about this command here.
Basically this sets up the right parameters to build for your specific model. The param can derived based on aosp_[device code]-[userdebug | eng | user].
Once you have run the above two commands, you can *finally* build your codebase.
Code:
m droid -j4
m basically makes and builds the whole codebase.
Code:
droid
refers to the defaults target configuration (optional). -jN is to specify parallelism (equal to number of cores you have).
This command could take anywhere between 4-12 hours for the first run. But, if you followed all steps above, you should have a green message in the end saying this
Code:
[COLOR="SeaGreen"]#### build completed successfully (2:03:04 (hh:mm:ss)) ####[/COLOR]
Flashing your phone
Now, you're 50% safe when your build has finished successfully. Now, next 50% depends if you're able to flash it and get the phone booting.
This part most of you should know, so I am keeping it brief.
Enter fastboot
Code:
adb reboot bootloader
Unlock your bootloader
Code:
fastboot flashing unlock
Flash your Build
From the root folder of your repository (~/aosp/pixel3)
Code:
fastboot flashall -w
In a few minutes your device should be booting to the freshing baked ROM that you made.
What next?
You can just repeat
Code:
m droid -j4
to repeat builds
You can also go to a specific module folder and execute
Code:
mm
to only build that module
You can use adb sync to update specific modules without flashing again (this never worked for me, always bricked my device)
Use *fastboot flashall* without [-w] flag to flash over existing ROM without losing user data.
You can clean up the whole builds and rebuild everything from scratch. Run
Code:
make clobber
to clean your build, and use
Code:
m
to build again
You could face adb issues (device not detected) in Ubuntu. I am not going into details of how to fix that
This has been pretty much my journey so far with AOSP. I am comfortable making changes to modules and building them again.
Aw man, thanks for posting this. Never thought building rom itself would take this much effort & resources. Rom devs are serioulsy awesome ppl. :good:
Thx a lot ,I just want to learn it,it is vevy clear and help me a lot
Thanks very much for creating this. I didn't try flashing the result yet, but the build finished without any problems.
thank you very much for your post, I also want to modify little bit in code aosp and test this changes. Could you plaese provide advice about how I can open code (Android studio?), do some changes and test it by emulator?
thanks for the great guide
but following it gapps will not be included in the build, correct?
do you guys know how to include open gapps?
tia!
hi everything worked in this guide in terms of the build. While flashing the device all steps succeed but during boot the pixel is stuck at the google loading screen. Any suggestions. I have been stuck on the screen for > 30 minutes.
rorlig said:
hi everything worked in this guide in terms of the build. While flashing the device all steps succeed but during boot the pixel is stuck at the google loading screen. Any suggestions. I have been stuck on the screen for > 30 minutes.
Click to expand...
Click to collapse
Maybe you did not download appropriate .sh scripts for your device or didn't run them successfully before building the code. These scripts additionally download files and without them you could have these problems which you mentioned.
I built and loaded AOSP Andorid 9 for PIxel 2 using the eng build vs the userdebug and its works however, when I start installing and granting Google services and such it works but i get a lot of crashes. do you have Google working and not crashing all the time?
```
$ adb root
$ adb remount
$ adb shell
$ cd /system/priv-app
$ mkdir GoogleServicesFramework
$ mkdir Phonesky
$ mkdir PrebuiltGmsCorePi
$ cp /sdcard/GoogleServicesFramework.apk GoogleServicesFramework/GoogleServicesFramework.apk
$ cp /sdcard/Phonesky.apk Phonesky/Phonesky.apk
$ cp /sdcard/PrebuiltGmsCorePi.apk PrebuiltGmsCorePi/PrebuiltGmsCorePi.apk
$ chmod 755 GoogleServicesFramework
$ chmod 755 Phonesky
$ chmod 755 PrebuiltGmsCorePi
$ chmod 644 GoogleServicesFramework/GoogleServicesFramework.apk
$ chmod 644 Phonesky/Phonesky.apk
$ chmod 644 PrebuiltGmsCorePi/PrebuiltGmsCorePi.apk
:: Need to add permissions for the three apps above
::If a device fails to boot, you need to logcat and grep for " - not in privapp-permissions whitelist" and add any missing items in the xml
$ adb push C:\Users\username\Desktop\PIxel2_9.0.0_eng_build\privapp-permissions-platform.xml /etc/permissions/privapp-permissions-platform.xml
```
Hello, I'm interested on the Mac os part. I've been building pixel experience on Ubuntu form am external HDD but because it's a 2011 iMac I have USB 2.0 and r/w speeds are really low slowering the whole process. On the internal drive I have a 500gb SSD that I'd like to use for compiling but partitioning is not an option, could you help me setting up enviroment?
PD: I tried setting it up with brew but I am missing dependencies I can't (don't know how) install them with brew, all guides are for Ubuntu or for Mac is but old.
Thank you in advance!
This guide inspired me to setup a Dockerized build and flash environment for the Pixel 5.
Leaving it here as Pixel 3 owners might find it useful: https://github.com/nvllsvm/pixel5-aosp-builder
Draje0 said:
This guide inspired me to setup a Dockerized build and flash environment for the Pixel 5.
Leaving it here as Pixel 3 owners might find it useful: https://github.com/nvllsvm/pixel5-aosp-builder
Click to expand...
Click to collapse
Thanks, this is very helpful! Have you tested the built image on a pixel 5?
ammarr said:
Thanks, this is very helpful! Have you tested the built image on a pixel 5?
Click to expand...
Click to collapse
Yup - it boots and seems to work except for phone call audio (T-Mobile US).
I am having issue, I did this and got:
#### build completed successfully (17:26:44 (hh:mm:ss)) ####
Click to expand...
Click to collapse
flashing claims to have succeeded but when the phone reboots it just goes back to fastboot mode and says "no valid slot too boot to"
The last few lines of output when doing "fastboot flashall -w" are:
Erase successful, but not automatically formatting.
File system type raw not supported.
Erasing 'metadata' OKAY [ 0.007s]
Erase successful, but not automatically formatting.
File system type raw not supported.
Rebooting OKAY [ 0.000s]
Finished. Total time: 82.933s
Click to expand...
Click to collapse
Is the filesystem raw not supported normal? Other than that I am really not sure why this isn't working.
very very handy post, appreciate it, even though i would probably be not building on my own. 20GB smh.. phew!
Anyone know or figure out how to get gapps on this once built (or built-in) without having to have TWRP?
Great guide. I am working on creating a custom rom myself. I've been wondering if it's possible to prevent system apps from being included in the build. There are a few apps that I use f-droid apps in their place (example K9 mail for stock email app) and don't want to see them re-appear when the ROM is updated. If this is not possible, can they be removed from the build before flashing?
Edit ..
Figured it out.
Hi.. I'm Building AOSP 10 for POCO F1(beryllium). i dont know which command should i choose in lunch cause my device isnt listed.. They have only for Pixel Devices.. Pls guide through it
***Key step: Download radio drivers.***
Most tutorials miss this or mention it very subtly. But, without this step the ROM you flash won't boot to the home screen (you will be in the boot loop).
Go to the driver binaries page, and download the right zip files for the Android build version (android-10.0.0_r10) and device (Pixel 3) you chose earlier in the repo command.
You will be downloading two zip files (one vendor image zip and one radio drivers zip), both zips will have on shell script file each (.sh), just put those two files in your repo folder (~aosp/pixel3) and run the scripts. It will download the required proprietary files (after asking you to accept the terms). Do not miss this step.. I lost 3 days trying to find the reason for my ROM not booting up, this was it.***
How can I get this 2 zip files for my Samsung device (SM-A715F). Thank you
Ubuntu 20.04 sees phone with Linux adb v28 using 'adb devices'.
I've installed the usb driver for my Blackview A80 phone in VirtualBox Windows 10 VM. However, VirtualBox Windows 10 VM fails to see my phone with adb (v1.0.32 & 1.0.39). I'd like to download adb.exe v1.0.40 (as that's the requirement to run B4A Windows app under Wine in Ubuntu.). But I can't find that version anywhere. Has anyone got adb.exe v1.0.40?
I've followed the instructions on
http://adbcommand.com/articles/How to build adb(1.0.40) for windows on Ubuntu but I get 'fatal: cannot make .repo directory: Permission denied' on the step
repo init -u https://android.googlesource.com/platform/manifest. I know nothing about repo. Anybody have any ideas about this repo problem?
johnaaronrose1 said:
Ubuntu 20.04 sees phone with Linux adb v28 using 'adb devices'.
I've installed the usb driver for my Blackview A80 phone in VirtualBox Windows 10 VM. However, VirtualBox Windows 10 VM fails to see my phone with adb (v1.0.32 & 1.0.39). I'd like to download adb.exe v1.0.40 (as that's the requirement to run B4A Windows app under Wine in Ubuntu.). But I can't find that version anywhere. Has anyone got adb.exe v1.0.40?
I've followed the instructions on
http://adbcommand.com/articles/How to build adb(1.0.40) for windows on Ubuntu but I get 'fatal: cannot make .repo directory: Permission denied' on the step
repo init -u https://android.googlesource.com/platform/manifest. I know nothing about repo. Anybody have any ideas about this repo problem?
Click to expand...
Click to collapse
have you tried using chocolatey on the windows VM, to see if their adb source works for you?
you would need chocolately preinstalled, this thread would explain better.
How To Use Chocolatey
========================= ============================================ HOW TO USE CHOCOLATEY ============== ============= Hi Friends~! This amazing package manager changed my Windoz life
forum.xda-developers.com
after you have chocolatey installed, you would run this command:
choco install adb
essentially, it will dl the latest adb, and wrap all it's variables with the correct permissions, even in a vm. I'm not sure if this will help you, but just wanted to put it out there~!
Have a good day~!
jenneh said:
have you tried using chocolatey on the windows VM, to see if their adb source works for you?
you would need chocolately preinstalled, this thread would explain better.
How To Use Chocolatey
========================= ============================================ HOW TO USE CHOCOLATEY ============== ============= Hi Friends~! This amazing package manager changed my Windoz life
forum.xda-developers.com
after you have chocolatey installed, you would run this command:
choco install adb
essentially, it will dl the latest adb, and wrap all it's variables with the correct permissions, even in a vm. I'm not sure if this will help you, but just wanted to put it out there~!
Have a good day~!
Click to expand...
Click to collapse
The specified link does not AFAIK give instructions on how to install chocolately.
Oh It Does~! As well As a VM demonstration on how to install on an unlisted YT vid. But Okay~! Just trying to help ;-)
The link you supplied with its links to "How to install chocolately" sends me to an advertising site.
johnaaronrose1 said:
Ubuntu 20.04 sees phone with Linux adb v28 using 'adb devices'.
I've installed the usb driver for my Blackview A80 phone in VirtualBox Windows 10 VM. However, VirtualBox Windows 10 VM fails to see my phone with adb (v1.0.32 & 1.0.39). I'd like to download adb.exe v1.0.40 (as that's the requirement to run B4A Windows app under Wine in Ubuntu.). But I can't find that version anywhere. Has anyone got adb.exe v1.0.40?
I've followed the instructions on
http://adbcommand.com/articles/How to build adb(1.0.40) for windows on Ubuntu but I get 'fatal: cannot make .repo directory: Permission denied' on the step
repo init -u https://android.googlesource.com/platform/manifest. I know nothing about repo. Anybody have any ideas about this repo problem?
Click to expand...
Click to collapse
Would this help?
Android SDK Platform Tools for Windows
Android Debug Bridge version 1.0.26 platform-tools_r03-windows.zip (2011-02-23) platform-tools_r04-windows.zip (2011-05-10) platform-to...
cxzstuff.blogspot.com