AOSP 環境にて Google Apps をビルドする [ Android 11 ]
AOSP 環境にて Google Apps をビルドしてみる。
Google Apps として、Open GAppsを使用する。
Open GAppsのリンク先にあるビルド済みパッケージは、Android8.0以降うまく動作しなくなった。
したがって、ローカルにある AOSP 環境に Google Apps 環境をダウンロードし、ビルドする必要がある。
ローカルビルド用の Google Apps 環境として、こちらを使用する。
なお下記は、Pixel3 向けの手順となる。
1. manifest.xml ファイルを修正する
.repo/manifest.xml
ファイルに、下記のように<!-- Open GApps [S] -->
から<!-- Open GApps [E] -->
を追記する。
<?xml version="1.0" encoding="UTF-8"?> <!-- DO NOT EDIT THIS FILE! It is generated by repo and changes will be discarded. If you want to use a different manifest, use `repo init -m <file>` instead. If you want to customize your checkout by overriding manifest settings, use the local_manifests/ directory instead. For more information on repo manifests, check out: https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md --> <manifest> <include name="default.xml" /> <!-- Open GApps [S] --> <remote name="opengapps" fetch="https://github.com/opengapps/" /> <remote name="opengapps-gitlab" fetch="https://gitlab.opengapps.org/opengapps/" /> <project path="vendor/opengapps/build" name="aosp_build" revision="master" remote="opengapps" /> <project path="vendor/opengapps/sources/all" name="all" clone-depth="1" revision="master" remote="opengapps-gitlab" /> <!-- arm64 depends on arm --> <project path="vendor/opengapps/sources/arm" name="arm" clone-depth="1" revision="master" remote="opengapps-gitlab" /> <project path="vendor/opengapps/sources/arm64" name="arm64" clone-depth="1" revision="master" remote="opengapps-gitlab" /> <!-- Pixel では使用しない <project path="vendor/opengapps/sources/x86" name="x86" clone-depth="1" revision="master" remote="opengapps-gitlab" /> <project path="vendor/opengapps/sources/x86_64" name="x86_64" clone-depth="1" revision="master" remote="opengapps-gitlab" /> --> <!-- Open GApps [E] --> </manifest>
2. リポジトリを同期する
上記の 1. で追加したリポジトリをローカル環境にコピーする。
下記全て同期するとおよそ36GB消費する。
aosp_build
を同期
# vendor/opengapps/build $ repo sync aosp_build Fetching: 100% (1/1), done in 2.617s repo sync has finished successfully.
all
を同期
以降同期するリポジトリにはラージファイルが存在するため、あらかじめgit-lfs
をインストールする必要がある。
# git-lfsのインストール $ sudo apt install git-lfs # vendor/opengapps/sources/all $ repo sync all Fetching: 100% (1/1), done in 25.207s repo sync has finished successfully. # フォルダに移動 $ cd ~/<AOSP のルートパス>/vendor/opengapps/sources/all/ # ラージファイルを pull する # git-lfsはフェッチしたプロジェクトにて初期化済み $ git lfs pull
arm
を同期
# vendor/opengapps/sources/arm $ repo sync arm Fetching: 100% (1/1), done in 2.074s repo sync has finished successfully. # フォルダに移動 $ cd ~/<AOSP のルートパス>/vendor/opengapps/sources/arm/ # ラージファイルを pull する # git-lfsはフェッチしたプロジェクトにて初期化済み $ git lfs pull
arm64
を同期
# vendor/opengapps/sources/arm64 $ repo sync arm64 Fetching: 100% (1/1), done in 4.731s repo sync has finished successfully. # フォルダに移動 $ cd ~/<AOSP のルートパス>/vendor/opengapps/sources/arm64/ # ラージファイルを pull する # git-lfsはフェッチしたプロジェクトにて初期化済み $ git lfs pull
3. device.mk ファイルを修正する
device/google/crosshatch/device.mk
ファイルに、下記のように# ADD_GAPPS[S]
から# ADD_GAPPS[E]
を追記する。
使用するデバイスにより修正すべきdevice.mk
ファイルが存在するフォルダは異なる。
上記のdevice/google/crosshatch
フォルダは、Pixel3、Pixel3XL用となる。
GAPPS_VARIANT
に指定する値はこちらを参照する。
GAPPS_VARIANT := stock
が推奨パッケージ。
SetupWizard
とPixelLauncher
は正しく起動しないため、その対策を行う。
# # Copyright (C) 2016 The Android Open-Source Project # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # ADD_GAPPS[S] # mini 以上のパッケージでないと Google Maps が起動しなかった # stock が推奨パッケージ GAPPS_VARIANT := mini #micro #nano #pico # 端末初回起動時のセットアップウィザードが正しく起動しないため削除 GAPPS_EXCLUDED_PACKAGES += \ SetupWizard \ # AOSP 標準ランチャー(Launcher3QuickStep)がオーバーライドされるのを防ぐ # PixelLauncher は正しく起動しない GAPPS_BYPASS_PACKAGE_OVERRIDES += \ PixelLauncher \ # ADD_GAPPS[E] PRODUCT_SOONG_NAMESPACES += \ device/google/crosshatch \ hardware/google/av \ hardware/google/camera \ hardware/google/interfaces \ hardware/google/pixel \ hardware/qcom/sdm845 \ vendor/google/camera \ vendor/qcom/sdm845 \ vendor/google/interfaces ##### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ##### device.mk ファイル 終端 include hardware/google/pixel/pixelstats/device.mk include hardware/google/pixel/mm/device_legacy.mk include hardware/google/pixel/thermal/device.mk # power HAL -include hardware/google/pixel/power-libperfmgr/aidl/device.mk # ADD_GAPPS[S] $(call inherit-product, vendor/opengapps/build/opengapps-packages.mk) # ADD_GAPPS[E]
4. ビルドを行う
いつも通りmake
にてビルドを行う。
$ make -j8
5. 注意点
git-lfs
をインストールする前にall
リポジトリをrepo sync
すると、ラージファイルの情報を取得できないため、リポジトリがおかしくなる(git-lfs
で取得するファイルがdeleted
でステージされてしまう)。
上記を防ぐために、まず最初にgit-lfs
のインストールを行う必要がある。
# git-lfsのインストールを行わないで repo sync を行うと下記エラーが出る # vendor/opengapps/sources/all $ repo sync all Fetching: 100% (1/1), done in 6.978s git-lfs filter-process --skip: 1: git-lfs filter-process --skip: git-lfs: not found fatal: The remote end hung up unexpectedly error: Cannot checkout all: GitError: Cannot initialize work tree for all Traceback (most recent call last):