-
Notifications
You must be signed in to change notification settings - Fork 1
/
Guide.bat
218 lines (166 loc) · 8.15 KB
/
Guide.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
####################################
# #
# 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 "[email protected]"
#####################################
# 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.
# Copyright (C) 2016-2017 Nathan Chancellor
#
# This guide is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This guide is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>