想内置应用到/data/用户区,让其可卸载
系统android 8(O)
android 11可查看另外一篇《android 11®预装APP到data/app目录》
假设是添加myapplication.apk到sdk中的, 烧录后要装到/data/区(注意此方法恢复出厂后app会消失)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Module name should match apk name to be installed
LOCAL_MODULE := myapplication
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX)
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
include $(BUILD_PREBUILT)
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS) 由这行来控制安装到data/app下。
在PRODUCT_PACKAGES下添加myapplication
PRODUCT_PACKAGES += myapplication
编译后,在out目录下能搜索到myapplication.apk,但是烧录到设备后,启动找不到这个app
在sdk下搜索PackageManagerService.java,不同的平台可能位置不一样,
比如
frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
在PackageManagerService.java文件中搜索关键字not found; ignoring,把它对应的抛出异常的
代码屏蔽掉
diff --git a/base/services/core/java/com/android/server/pm/PackageManagerService.java b/base/services/core/java/com/android/server/pm/PackageManagerService.java
index 238a70f6..f380a66e 100644
--- a/base/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/base/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -12095,11 +12095,11 @@ public class PackageManagerService extends PackageManagerServiceExAbs+ " but expected at " + known.codePathString+ "; ignoring.");}
- } else {
+ } /*else {throw new PackageManagerException(INSTALL_FAILED_INVALID_INSTALL_LOCATION,"Application package " + pkg.packageName+ " not found; ignoring.");
- }
+ }*/}}
作者:帅得不敢出门