最終更新:2021-11-26 (金) 16:58:38 (1175d)
Android/ビルド
Codelab?
手順
Eclipseの設定
カスタマイズ
容量
ビルド前
- repo sync
AOSP/ブランチ ソースコード .repo含める android-5.1.1_r1 14.5GB 33.7GB android-4.4.4_r1? 9.4 GB 43.1GB
Ubuntu/バージョン
JDK/バージョン
- JDK 8 to build the master branch of Android in the Android Open Source Project (AOSP);
- JDK 7: for Lollipop through Marshmallow
- JDK 6 to build Gingerbread through KitKat;
- JDK 5 for Cupcake through Froyo. See Initializing a Build Environment for installation instructions by operating system.
ビルド環境の準備
オフィシャル
Ubuntu 10.04 LTS (Lucid) for versions < JB 4.2.1Ubuntu 12.04 LTS (Precise Pangolin) for versions >= JB 4.2.1- Ubuntu 14.04 - 最近はこれ (Android/ビルド/Ubuntu 14.04)
ホストOS
Ubuntu
- Ubuntu 10.04 - 推奨
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \ x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \ libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \ libxml2-utils xsltproc
- Ubuntu 10.10
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
- Ubuntu 11.04
?
- Ubuntu 11.10
$ sudo apt-get install libx11-dev:i386
- Ubuntu 12.04 (Android/ビルド/Ubuntu 12.04)
$ sudo apt-get install 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 tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
- Ubuntu 12.10
64bit
- Gingerbread (Android 2.3)以降は64bit環境でビルドする必要がある
仮想マシンでビルドする場合
- メモリ:16GB
- ディスク:30GB以上
必要なパッケージ
Android/ソースコードのダウンロード
- Repoっていうツールを使ってダウンロードする
http://source.android.com/source/downloading.html
Repoのインストール
mkdir ~/bin PATH=~/bin:$PATH curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo chmod a+x ~/bin/repo
ソースコードのダウンロード
mkdir WORKING_DIRECTORY cd WORKING_DIRECTORY repo init -u https://android.googlesource.com/platform/manifest repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1 repo sync
Binaries for Nexus Phones
- Starting with Ice Cream Sandwich, the Android Open-Source Project can't be used from pure source code only, and requires additional hardware-related proprietary libraries to run, specifically for hardware graphics acceleration.
- Official binaries for Nexus S, Nexus S 4G?, Galaxy Nexus, Nexus 7, and PandaBoard can be downloaded.
Android/Linuxカーネル
- ICSではビルド時間削減のためにカーネルのソースコードがツリーになく、あらかじめビルドされたバイナリ形式で提供されている。
- AOSP/deviceのデバイスごとのフォルダに含まれている
- Android/Linuxカーネル/ビルド
ビルド
http://source.android.com/source/building.html
$ source build/envsetup.sh $ . build/envsetup.sh $ lunch full-eng //ターゲットの選択 $ make -j4 //ビルド開始
ビルド用のコマンドを有効化
source build/envsetup.sh
- AOSP/build/envsetup.sh
lunch
- ビルドに関する各種個別情報を設定するenvsetup.shの関数
lunch <BUILD>-<BUILDTYPE>
- 例
- lunch aosp_hammerhead-userdebug
BUILD
ビルド名 デバイス名 メモ aosp_arm ARM emulator AOSP, fully configured with all languages, apps, input methods aosp_maguro maguro AOSP, running on Galaxy Nexus GSM/HSPA+ ("maguro") aosp_panda panda AOSP, running on PandaBoard ("panda") - mini_emulator
- 昔の
full emulator fully configured with all languages, apps, input methods full_maguro maguro full build running on Galaxy Nexus GSM/HSPA+ ("maguro") full_panda panda full build running on PandaBoard ("panda")
BUILDTYPE
- Android/ビルドタイプ
build type use ro.secure ro.debuggable ro.kernel.android.checkjni adb user limited access; suited for production 1 0 0 off userdebug like "user" but with root access and debuggability; preferred for debugging 0 1 0 on eng development configuration with additional debugging tools 0 1 1 on
デバイス別の推奨オプション/ブランチ
例
$ lunch You're building on Linux Lunch menu... pick a combo: 1. aosp_arm-eng 2. aosp_arm64-eng 3. aosp_mips-eng 4. aosp_mips64-eng 5. aosp_x86-eng 6. aosp_x86_64-eng 7. aosp_hammerhead-userdebug 8. aosp_mako-userdebug 9. aosp_flounder-userdebug 10. aosp_shamu-userdebug 11. mini_emulator_mips-userdebug 12. mini_emulator_arm64-userdebug 13. mini_emulator_x86-userdebug 14. mini_emulator_x86_64-userdebug 15. m_e_arm-userdebug 16. aosp_manta-userdebug 17. aosp_flo-userdebug 18. aosp_grouper-userdebug 19. full_fugu-userdebug 20. aosp_fugu-userdebug 21. aosp_deb-userdebug 22. aosp_tilapia-userdebug Which would you like? [aosp_arm-eng] aosp_flo-userdebug ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=5.1.1 TARGET_PRODUCT=aosp_flo TARGET_BUILD_VARIANT=userdebug TARGET_BUILD_TYPE=release TARGET_BUILD_APPS= TARGET_ARCH=arm TARGET_ARCH_VARIANT=armv7-a-neon TARGET_CPU_VARIANT=krait TARGET_2ND_ARCH= TARGET_2ND_ARCH_VARIANT= TARGET_2ND_CPU_VARIANT= HOST_ARCH=x86_64 HOST_OS=linux HOST_OS_EXTRA=Linux-3.16.0-30-generic-x86_64-with-Ubuntu-14.04-trusty HOST_BUILD_TYPE=release BUILD_ID=LMY47V OUT_DIR=out ============================================
Android/make
make -j<タスク数>
- between 1 and 2 times the number of hardware threads on the computer being used for the build.
AOSP/Makefile
Common make targets: ---------------------------------------------------------------------------------- make droid Default target make clean (aka clobber) equivalent to rm -rf out/ make snod Quickly rebuild the system image from built packages make offline-sdk-docs Generate the HTML for the developer SDK docs make doc-comment-check-docs Check HTML doc links & validity, without generating HTML make libandroid_runtime All the JNI framework stuff make framework All the java framework stuff make services The system server (Java) and friends make help You're reading it right now
ccache
- Android 4.0から対応
export USE_CCACHE=1 prebuilt/linux-x86/ccache/ccache -M 50G
Eclipseでの開発
スライド
ビルドプロセス
- Set up standard variables
- Clean up (AOSP/build/core/cleanbuild.mk?)
- Find all Android.mk
- Generate dependencies
- Build modules
- Make Images
参考
http://qiita.com/TNaruto/items/9d5a3bbec1f17e67d1b6
https://web.archive.org/web/20140512210047/http://events.linuxfoundation.org/images/stories/slides/abs2013_melski.pdf?a