LoginSignup
0
0

More than 1 year has passed since last update.

Android studioで開発したアプリをHikey960 AOSPソースツリーに組み込む

Posted at
  1. Android Studio でアプリ(ここではServiceTestとする)を開発
  2. プロジェクトディレクトリをまるごとAOSPのソースツリーのpackages/apps/以下にコピー
  3. Android.bpを記述して、packages/apps/ServiceTestに置く。
package {
   // See: http://go/android-license-faq
   default_applicable_licenses: ["Android-Apache-2.0"],
}

android_app {
   name: "ServiceTest",
   defaults: ["platform_app_defaults"],
   platform_apis: true,
   manifest: "app/src/main/AndroidManifest.xml",
   srcs: [
      "app/src/main/java/**/*.java"
   ],
   resource_dirs: [
      "app/src/main/res"
   ],
   enabled: true,
   static_libs: [
       "com.google.android.material_material",
   ],
}

4. 以下のコマンドでビルド

$ . ./build/envsetup.sh
$ lunch hikey960-userdebug
$ make -j8

Android.bpにcom.google.android.material_materialを指定しない場合、ビルド時、下記のエラーが出た。

FAILED: out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/package-res.apk out/soong/.intermediates/package
s/apps/ServiceTest/ServiceTest/android_common/gen/proguard.options out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/andr
oid_common/gen/android/R.srcjar out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/R.txt out/soong/.interme
diates/packages/apps/ServiceTest/ServiceTest/android_common/extra_packages
rm -rf out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/gen/aapt2/R && out/host/linux-x86/bin/aapt2 link 
-o out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/package-res.apk --no-static-lib-packages --manifest o
ut/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/manifest_fixer/AndroidManifest.xml  --min-sdk-version Ups
ideDownCake --target-sdk-version UpsideDownCake --version-code 33 --version-name  UpsideDownCake -I out/soong/.intermediates/framework
s/base/core/res/framework-res/android_common/package-res.apk --product default -c en_US,en_US,af_ZA,am_ET,ar_EG,ar_XB,as_IN,az_AZ,be_B
Y,bg_BG,bn_BD,bs_BA,ca_ES,cs_CZ,da_DK,de_DE,el_GR,en_AU,en_CA,en_GB,en_IN,en_XA,es_ES,es_US,et_EE,eu_ES,fa_IR,fi_FI,fr_CA,fr_FR,gl_ES,
gu_IN,hi_IN,hr_HR,hu_HU,hy_AM,in_ID,is_IS,it_IT,iw_IL,ja_JP,ka_GE,kk_KZ,km_KH,kn_IN,ko_KR,ky_KG,lo_LA,lt_LT,lv_LV,mk_MK,ml_IN,mn_MN,mr
_IN,ms_MY,my_MM,nb_NO,ne_NP,nl_NL,or_IN,pa_IN,pl_PL,pt_BR,pt_PT,ro_RO,ru_RU,si_LK,sk_SK,sl_SI,sq_AL,sr_Latn_RS,sr_RS,sv_SE,sw_TZ,ta_IN
,te_IN,th_TH,tl_PH,tr_TR,uk_UA,ur_PK,uz_UZ,vi_VN,zh_CN,zh_HK,zh_TW,zu_ZA,en_XC, --java out/soong/.intermediates/packages/apps/ServiceT
est/ServiceTest/android_common/gen/aapt2/R --proguard out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/ge
n/proguard.options --output-text-symbols out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/R.txt @out/soon
g/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/aapt2/res.list && out/host/linux-x86/bin/soong_zip -write_if_cha
nged -jar -o out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/gen/android/R.srcjar -C out/soong/.intermed
iates/packages/apps/ServiceTest/ServiceTest/android_common/gen/aapt2/R -D out/soong/.intermediates/packages/apps/ServiceTest/ServiceTe
st/android_common/gen/aapt2/R &&out/host/linux-x86/bin/extract_jar_packages -i out/soong/.intermediates/packages/apps/ServiceTest/Serv
iceTest/android_common/gen/android/R.srcjar -o out/soong/.intermediates/packages/apps/ServiceTest/ServiceTest/android_common/extra_pac
kages --prefix '--extra-packages '
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:13: error: resource attr/colorPrimaryVariant (aka com.example.servicetest
:attr/colorPrimaryVariant) not found.
error: resource style/Theme.MaterialComponents.DayNight.DarkActionBar (aka com.example.servicetest:style/Theme.MaterialComponents.DayN
ight.DarkActionBar) not found.
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:5: error: style attribute 'attr/colorPrimary (aka com.example.servicetest
:attr/colorPrimary)' not found.
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:6: error: style attribute 'attr/colorPrimaryVariant (aka com.example.serv
icetest:attr/colorPrimaryVariant)' not found.
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:7: error: style attribute 'attr/colorOnPrimary (aka com.example.servicete
st:attr/colorOnPrimary)' not found.
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:9: error: style attribute 'attr/colorSecondary (aka com.example.servicete
st:attr/colorSecondary)' not found.
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:10: error: style attribute 'attr/colorSecondaryVariant (aka com.example.s
ervicetest:attr/colorSecondaryVariant)' not found.
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:11: error: style attribute 'attr/colorOnSecondary (aka com.example.servic
etest:attr/colorOnSecondary)' not found.
packages/apps/ServiceTest/app/src/main/res/values/themes.xml:13: error: resource attr/colorPrimaryVariant (aka com.example.servicetest
:attr/colorPrimaryVariant) not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:13: error: resource attr/colorPrimaryVariant (aka com.example.servi
cetest:attr/colorPrimaryVariant) not found.
error: resource style/Theme.MaterialComponents.DayNight.DarkActionBar (aka com.example.servicetest:style/Theme.MaterialComponents.DayN
ight.DarkActionBar) not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:5: error: style attribute 'attr/colorPrimary (aka com.example.servi
cetest:attr/colorPrimary)' not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:6: error: style attribute 'attr/colorPrimaryVariant (aka com.exampl
e.servicetest:attr/colorPrimaryVariant)' not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:7: error: style attribute 'attr/colorOnPrimary (aka com.example.ser
vicetest:attr/colorOnPrimary)' not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:9: error: style attribute 'attr/colorSecondary (aka com.example.ser
vicetest:attr/colorSecondary)' not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:10: error: style attribute 'attr/colorSecondaryVariant (aka com.exa
mple.servicetest:attr/colorSecondaryVariant)' not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:11: error: style attribute 'attr/colorOnSecondary (aka com.example.
servicetest:attr/colorOnSecondary)' not found.
packages/apps/ServiceTest/app/src/main/res/values-night/themes.xml:13: error: resource attr/colorPrimaryVariant (aka com.example.servi
cetest:attr/colorPrimaryVariant) not found.
error: failed linking references.
02:07:03 ninja failed with: exit status 1

5. device/linaro/hikeydevice-common.mkに以下を追記

diff --git a/device-common.mk b/device-common.mk
index 217994f..2e44a58 100644
--- a/device-common.mk
+++ b/device-common.mk
@@ -269,5 +269,7 @@ PRODUCT_PACKAGES += \
PRODUCT_PACKAGES += \
    suspend_blocker

+PRODUCT_PACKAGES += ServiceTest
+
TARGET_PRODUCT_PROP := $(LOCAL_PATH)/product.prop
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := device/linaro/hikey/bluetooth
0
0
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
0
0