1、下载并添加到源码中,如:alps/vendor/google_r6:
2、修改项目配置,device/maisui/projectname/ProjectConfig.mk:
MTK_GAUGE_VERSION = 30
MTK_SWIP_WMAPRO = no
BUILD_AGO_GMS = no
+# add for gms start
+BUILD_GMS = yes
+# add for gms end
MTK_RCS_UA_SUPPORT = no
MTK_GPU_VERSION = mali bifrost r20p0
MTK_GPU_COMMON_DVFS_SUPPORT = yes
3、把gms.mk加入到项目编译中
+# add for gms start
+# GMS interface
+ifdef BUILD_GMS
+ifeq ($(strip $(BUILD_GMS)), yes)
+ ifeq ($(strip $(BUILD_AGO_GMS)), yes)
+ $(call inherit-product-if-exists, vendor/google_r6/products/gms_go.mk)
+ else
+$(call inherit-product-if-exists, vendor/google_r6/products/gms.mk)
+ endif
+
+endif
+endif
+# add for gms end
4、修改device/mediatek/common/device.mk
@@ -4851,33 +4851,33 @@ endif
# From Android Q, GMS devices must preload Google signed Mainline module release
ifeq ($(BUILD_GMS), yes)
# Mainline module overlay
- PRODUCT_PACKAGES += \
+ #PRODUCT_PACKAGES += \
GoogleExtServicesConfigOverlay \
GooglePermissionControllerOverlay \
GooglePermissionControllerFrameworkOverlay
- PRODUCT_PACKAGE_OVERLAYS += device/mediatek/common/overlay/mainline
+ #PRODUCT_PACKAGE_OVERLAYS += device/mediatek/common/overlay/mainline
# Mainline common and must APK
- PRODUCT_PACKAGES += \
+ #PRODUCT_PACKAGES += \
GoogleExtServicesPrebuilt \
ModuleMetadataGooglePrebuilt \
GooglePermissionControllerPrebuilt
# Mainline other APK dependent on A-Go configuration
- ifneq ($(strip $(MTK_GMO_RAM_OPTIMIZE)), yes)
- PRODUCT_PACKAGES += \
+ #ifneq ($(strip $(MTK_GMO_RAM_OPTIMIZE)), yes)
+ # PRODUCT_PACKAGES += \
GoogleDocumentsUIPrebuilt\
GoogleCaptivePortalLogin\
GoogleNetworkStack\
GoogleNetworkPermissionConfig
- PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES := vendor/partner_modules/NetworkStackPrebuilt
- else
- PRODUCT_PACKAGES += \
+ # PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES := vendor/partner_modules/NetworkStackPrebuilt
+ #else
+ # PRODUCT_PACKAGES += \
InProcessNetworkStack \
PlatformCaptivePortalLogin \
PlatformNetworkPermissionConfig
- endif
+ # endif
ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29),)
# FBE device can support updatable APEX
修改device/mediatek/system/common/device.mk:
# From Android Q, GMS devices must preload Google signed Mainline module release
ifeq ($(BUILD_GMS), yes)
# Mainline module overlay
- PRODUCT_PACKAGES += \
+ #PRODUCT_PACKAGES += \
GoogleExtServicesConfigOverlay \
GooglePermissionControllerOverlay \
GooglePermissionControllerFrameworkOverlay
- PRODUCT_PACKAGE_OVERLAYS += device/mediatek/common/overlay/mainline
+ #PRODUCT_PACKAGE_OVERLAYS += device/mediatek/common/overlay/mainline
# Mainline common and must APK
- PRODUCT_PACKAGES += \
+ #PRODUCT_PACKAGES += \
GoogleExtServicesPrebuilt \
ModuleMetadataGooglePrebuilt \
GooglePermissionControllerPrebuilt
# Mainline other APK dependent on A-Go configuration
- ifneq ($(strip $(MTK_GMO_RAM_OPTIMIZE)), yes)
- PRODUCT_PACKAGES += \
+ #ifneq ($(strip $(MTK_GMO_RAM_OPTIMIZE)), yes)
+ # PRODUCT_PACKAGES += \
GoogleDocumentsUIPrebuilt\
GoogleCaptivePortalLogin\
GoogleNetworkStack\
GoogleNetworkPermissionConfig
- PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES := vendor/partner_modules/NetworkStackPrebuilt
- else
- PRODUCT_PACKAGES += \
+ # PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES := vendor/partner_modules/NetworkStackPrebuilt
+ #else
+ # PRODUCT_PACKAGES += \
InProcessNetworkStack \
PlatformCaptivePortalLogin \
PlatformNetworkPermissionConfig
- endif
+ # endif
ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29),)
# FBE device can support updatable APEX
5、错误处理:
01-01 00:03:20.793 725 751 E MtkAgpsNative: safe_write reason=[Text file busy]26
01-01 00:03:20.942 1448 1448 E System : ******************************************
01-01 00:03:20.942 1448 1448 E System : ************ Failure starting system services
01-01 00:03:20.942 1448 1448 E System : java.lang.RuntimeException: There must be exactly one installer; found [ResolveInfo{7ad8d84 com.android.packageinstaller/.InstallStart m=0x608000}, ResolveInfo{e1ba96d com.google.android.packageinstaller/com.android.packageinstaller.InstallStart m=0x608000}]
01-01 00:03:20.942 1448 1448 E System : at com.android.server.pm.PackageManagerService.getRequiredInstallerLPr(PackageManagerService.java:3809)
01-01 00:03:20.942 1448 1448 E System : at com.android.server.pm.PackageManagerService.(PackageManagerService.java:3347)
01-01 00:03:20.942 1448 1448 E System : at com.android.server.pm.PackageManagerService.main(PackageManagerService.java:2331)
01-01 00:03:20.942 1448 1448 E System : at com.android.server.SystemServer.startBootstrapServices(SystemServer.java:765)
01-01 00:03:20.942 1448 1448 E System : at com.android.server.SystemServer.run(SystemServer.java:529)
01-01 00:03:20.942 1448 1448 E System : at com.android.server.SystemServer.main(SystemServer.java:364)
01-01 00:03:20.942 1448 1448 E System : at java.lang.reflect.Method.invoke(Native Method)
01-01 00:03:20.942 1448 1448 E System : at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
01-01 00:03:20.942 1448 1448 E System : at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
01-01 00:03:20.942 1448 1448 E Zygote : System zygote died with exception
代码中有两个packageinstaller,其它的packageinstaller不应该编译进去:
java.lang.RuntimeException: There must be exactly one installer; found [ResolveInfo{7ad8d84 com.android.packageinstaller/.InstallStart m=0x608000}, ResolveInfo{e1ba96d com.google.android.packageinstaller/com.android.packageinstaller.InstallStart m=0x608000}]
修改 vendor/google_r6/apps/GooglePackageInstaller/Android.mk :
###############################################################################
# GooglePackageInstaller
LOCAL_PATH := $(my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := GooglePackageInstaller
LOCAL_MODULE_OWNER := google
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_PRIVILEGED_MODULE := true
#LOCAL_PRODUCT_MODULE :=
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
# 排除MtkPackageInstaller
LOCAL_OVERRIDES_PACKAGES := PackageInstaller MtkPackageInstaller
#LOCAL_REQUIRED_MODULES :=
include $(BUILD_PREBUILT)