android之APP模組編譯
阿新 • • 發佈:2019-01-31
原文地址:http://blog.csdn.net/yaphet__s/article/details/45640627
一,如何把app編進系統
a.原始碼編譯,在packages/apps目錄下有安卓原生的app,以Bluetooth為例,原始碼根目錄下有Android.mk檔案:
packages\apps\Bluetooth
- LOCAL_PATH:= $(call my-dir)
- include $(CLEAR_VARS)
-
#負責清理除LOCAL_PATH外的其他LOCAL_XXX,這個清理動作是必須的,因為所有的編譯控制檔案由同一個GNU Make解析和執行,
- #其變數是全域性的。所以清理後才能避免相互影響。
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := \
- $(call all-java-files-under, src)
- LOCAL_PACKAGE_NAME := Bluetooth
- LOCAL_CERTIFICATE := platform
- #使用系統簽名
- LOCAL_JNI_SHARED_LIBRARIES := libbluetooth_jni
-
LOCAL_JAVA_LIBRARIES := javax.obex telephony-common mms-common
- LOCAL_STATIC_JAVA_LIBRARIES := com.android.vcard
- LOCAL_JAVA_LIBRARIES += com.broadcom.bt
- LOCAL_REQUIRED_MODULES := libbluetooth_jni bluetooth.default
- LOCAL_PROGUARD_ENABLED := disabled
- #不使用程式碼混淆的工具進行程式碼混淆,不設定則預設值為full,即將該工程程式碼全部混淆
- include $(BUILD_PACKAGE)
-
include $(call all-makefiles-under,$(LOCAL_PATH))
然後修改build下的mk檔案,增加藍芽模組,這樣在原始碼根目錄下執行make就會編譯到Bluetooth模組
\build\target\product\generic_no_telephony.mk
- PRODUCT_PACKAGES := \
- DeskClock \
- Bluetooth \ #增加藍芽模組
- Calculator \
b.apk編譯,針對沒有原始碼的第三方apk,修改Android.mk:
- LOCAL_PATH := $(call my-dir)
- include $(CLEAR_VARS)
- # Module name should match apk name to be installed
- LOCAL_MODULE := Animation
- LOCAL_MODULE_TAGS := optional
- LOCAL_SRC_FILES := Animation.apk
- LOCAL_MODULE_CLASS := APPS
- LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
- LOCAL_CERTIFICATE := PRESIGNED
- include $(BUILD_PREBUILT)
- PRODUCT_PACKAGES +=\
- PackageInstallerRenew\
- Video\
- TlrService\
- Animation\ #新增Animation模組
二,如何刪除app,使當前app不會編進系統
在packages/apps目錄下有安卓原生的app,有一些app是不需要的。
LOCAL_PACKAGE_NAME packages\apps\Bluetooth\Android.mk
- LOCAL_SRC_FILES := \
- $(call all-java-files-under, src)
- LOCAL_PACKAGE_NAME := Bluetooth5 #將Bluetooth重新命名為Bluetooth5。也可更改generic_no_telephony.mk
- #保證和generic_no_telephony.mk增加的模組名字不一致即可
- LOCAL_CERTIFICATE := platform