LoginSignup
6
4

More than 5 years have passed since last update.

Android - Gappsを導入してビルド

Posted at

AOSPのソースを取得してビルドしたものにはPlayストア等のGoogleアプリが含まれていないため、
フリーで公開されているGappsを導入してNexus9(flounder)向けビルドを試みる。

・Gapps
http://opengapps.org/

・Gappsを導入したビルド方法
https://github.com/opengapps/aosp_build

Gapps導入&ビルド手順(Nexus9向け)

ソース取得とGapps導入

1. Android OS (7.1.2)のビルドとHello Worldの「ソースコードのダウンロード」のrepo init~まで終わらせる。
2. ${ANDROID_BUILD_TOP}/.repo/manifest/default.xml の最後に以下を追記する。
...
+    <remote name="opengapps" fetch="https://github.com/opengapps/"  />
+
+    <project path="vendor/google/build" name="aosp_build" revision="master" remote="opengapps" />
+    <project path="vendor/opengapps/sources/all" name="all" clone-depth="1" revision="master" remote="opengapps" />
+
+    <!-- arm64 depends on arm -->
+    <project path="vendor/opengapps/sources/arm" name="arm" clone-depth="1" revision="master" remote="opengapps" />
+    <project path="vendor/opengapps/sources/arm64" name="arm64" clone-depth="1" revision="master" remote="opengapps" />
+
+    <project path="vendor/opengapps/sources/x86" name="x86" clone-depth="1" revision="master" remote="opengapps" />
+    <project path="vendor/opengapps/sources/x86_64" name="x86_64" clone-depth="1" revision="master" remote="opengapps" />
</manifest>
3. repo syncでソース取得
4. device\htc\flounder\device.mkの最初に以下を追記
device.mk
#
# Copyright (C) 2013 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.
#

+GAPPS_VARIANT := <variant>
...

variantはpackage typesから選択。

例:

device.mk
+GAPPS_VARIANT := stock
5. device\htc\flounder\device.mkの最後に以下を追記
device.mk
...
# Add dependency of the proprietary keystore.flounder module.
PRODUCT_PACKAGES += \
    libkeymaster_messages

+$(call inherit-product, vendor/google/build/opengapps-packages.mk)

ビルド

6. Android OS (7.1.2)のビルドとHello World「ソースのビルド」を実施

エラー1:

...
No private recovery resources for TARGET_DEVICE flounder
build/core/tasks/vendor_module_check.mk:59: *** Error: Product "aosp_flounder" cannot have overlay in vendor tree: vendor/google/build/overlay/pico vendor/google/build/overlay/webview/24 vendor/google/build/overlay/browser vendor/google/build/overlay/dialer vendor/google/build/overlay/mms.
build/core/ninja.mk:163: ターゲット 'out/build-aosp_flounder.ninja' のレシピで失敗しました
make: *** [out/build-aosp_flounder.ninja] エラー 1

[0;31m#### make failed to build some targets (02:19 (mm:ss)) ####[00m

aosp_flounderはベンダーツリーに↑のオーバーレイは持てないとのエラー。
よくわからないため、vendor\google\build\opengapps-packages.mkのDEVICE_PACKAGE_OVERLAYSあたりを
コメントアウトしたらこのエラーはなくなった。

opengapps-packages.mk
...
-DEVICE_PACKAGE_OVERLAYS += \
-    $(GAPPS_DEVICE_FILES_PATH)/overlay/pico
...
-ifeq ($(GAPPS_FORCE_WEBVIEW_OVERRIDES),true)
-ifneq ($(filter-out $(call get-allowed-api-levels),24),)
-DEVICE_PACKAGE_OVERLAYS += \
-    $(GAPPS_DEVICE_FILES_PATH)/overlay/webview/21
-else
-DEVICE_PACKAGE_OVERLAYS += \
-    $(GAPPS_DEVICE_FILES_PATH)/overlay/webview/24
-endif
PRODUCT_PACKAGES += \
    WebViewGoogle
-endif

-ifeq ($(GAPPS_FORCE_BROWSER_OVERRIDES),true)
-ifneq ($(filter $(call get-allowed-api-levels),23),)
-DEVICE_PACKAGE_OVERLAYS += \
-    $(GAPPS_DEVICE_FILES_PATH)/overlay/browser
-endif
PRODUCT_PACKAGES += \
    Chrome
-endif

-ifneq ($(filter $(call get-allowed-api-levels),23),)
-ifeq ($(GAPPS_FORCE_DIALER_OVERRIDES),true)
-DEVICE_PACKAGE_OVERLAYS += \
-    $(GAPPS_DEVICE_FILES_PATH)/overlay/dialer

PRODUCT_PACKAGES += \
    GoogleDialer
-endif
-endif

-ifeq ($(GAPPS_FORCE_MMS_OVERRIDES),true)
-DEVICE_PACKAGE_OVERLAYS += \
-   $(GAPPS_DEVICE_FILES_PATH)/overlay/mms

PRODUCT_PACKAGES += \
    PrebuiltBugle
-endif

ifeq ($(GAPPS_FORCE_PIXEL_LAUNCHER),true)
GAPPS_EXCLUDED_PACKAGES += \
    GoogleHome

-ifneq ($(filter $(call get-allowed-api-levels),25),)
-DEVICE_PACKAGE_OVERLAYS += \
-    $(GAPPS_DEVICE_FILES_PATH)/overlay/pixelicons

PRODUCT_PACKAGES += \
    PixelLauncherIcons
-endif

エラー2:

...
No private recovery resources for TARGET_DEVICE flounder
build/core/tasks/vendor_module_check.mk:64: *** Error: vendor PRODUCT_COPY_FILES file "vendor/opengapps/sources/all/etc/sysconfig/google.xml:system/etc/sysconfig/google.xml" has unknown owner.
build/core/ninja.mk:163: ターゲット 'out/build-aosp_flounder.ninja' のレシピで失敗しました
make: *** [out/build-aosp_flounder.ninja] エラー 1

[0;31m#### make failed to build some targets (40 seconds) ####[00m

https://github.com/opengapps/aosp_build/issues/23
https://stackoverflow.com/questions/17333191/building-aosp-vendor-module-check-mk-fail
↑記載のPRODUCT_RESTRICT_VENDOR_FILESをfalseにする方法でビルドは通るようになった。

device\htc\flounder\aosp_flounder.mk

aosp_flounder.mk
...
PRODUCT_NAME := aosp_flounder
PRODUCT_DEVICE := flounder
PRODUCT_BRAND := Android
PRODUCT_MODEL := AOSP on Flounder
PRODUCT_MANUFACTURER := HTC
-PRODUCT_RESTRICT_VENDOR_FILES := owner path
+PRODUCT_RESTRICT_VENDOR_FILES := false
...
[0;32m#### make completed successfully (02:44:51 (hh:mm:ss)) ####[00m

Gapps入りのビルドではsystem.imgが1GB程大きくなった。

Nexus9へ書き込み

$ adb reboot bootloader
$ fastboot flash boot <ビルドしたboot.imgのあるフォルダパス>/boot.img
$ fastboot flash system <ビルドしたsystem.imgのあるフォルダパス>/system.img
$ fastboot reboot

この後初期化を行う。

Gapps導入前

Screenshot_20170627-123118.png
Screenshot_20170627-123125.png

Gapps導入後

Screenshot_20170628-181854.png
Screenshot_20170629-031955.png
Screenshot_20170629-032001.png

Googleアプリがインストールされていることが確認できました。

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4