带有源码的apk预置到系统
如何将android stuido 下的android代码内置到 android源码中去呢?
- 在package/apps/下需要预置的APK的名字创建爱你一个新文件夹。 例如创建的应用名称是TopActivity
- 将在android studio下的TopActivity的\app\src\main目录下的 java res AndroidMainfest.xml文件拷贝到 创建的目录下
- 在TopActivity下创建 android 下创建Android.mk 文件
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS:=optional
LOCAL_STATIC_JAVA_LIBRARIES:=android-support-v4
LOCAL_SRC_FILES := \
$(call all-java-files-under, java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_PACKAGE_NAME := TopActivity
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
include $(BUILD_PACKAGE)
- TopActivity 应用需要android-support-v4的jar包,因此需要使用LOCAL_STATIC_JAVA_LIBRARIES 指定一些
- LOCAL_CERTIFICATE := platform 是系统的平台签名
- LOCAL_PRIVILEGED_MODULE := true 表示应用需要系统的权限
- 在package/apps/TopActivity/下 mmm .
- 在android源码的目录下 make snod 打包
带有jni文件的app
- 需要在 java res 下建立jni的文件目录
- 在目录下新建Android.mk
LOCAL_PATH:$(call my-dir)
#include $(CLEAR_VARS)
LOCAL_SHARED_LIBRARIES :=liblog libc
LOCAL_PRELINK_MODULE:=false
LOCAL_C_INCLUDES:=$(JNI_H_INCLUDE)
LOCAL_SRC_FILES: = \
hardcontrol.cpp
LOCAL_MODULE:=libhardcontrol
include $(BUILD_SHARED_LIBRARY)
- 在源码的目录下新建的Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS:=optional
LOCAL_SRC_FILES := \
$(call all-java-files-under, java)
LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
LOCAL_PACKAGE_NAME := LEDdemo
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
LOCAL_JNI_SHARED_LIBRARIES :=libhardcontrol
LOCAL_REQUIRED-MODULED:= libhardcontrol
include $(BUILD_PACKAGE)
此时需要指出JNI动态库
编译记录
Install: out/target/product/tiny4412/system/priv-app/LEDdemo/LEDdemo.apk
mkdir -p out/target/product/tiny4412/system/priv-app/LEDdemo/lib/arm ;ln -sf /system/lib/libhardcontrol.so out/target/product/tiny4412/system/priv-app/LEDdemo/lib/arm/libhardcontrol.so
无源码的apk内置android系统
- 内置讯飞输入法
- 将官网下载的讯飞输入法的apk明明为 FlyIME.apk
- 在package/apps/下创建FlyIME文件夹,在创建apps
目录:/packages/apps/FlyIME/apps
├── Android.mk
└── FlyIME.apk
创建的Android.mk的内容为
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Module name should match apk name to be installed
LOCAL_MODULE := FlyIME
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := $(LOCAL_MODULE).apk
LOCAL_MODULE_CLASS := APPS
LOCAL_MODULE_SUFFIX := $(COMMON_ANDROID_PACKAGE_SUFFIX) LOCAL_PREBUILT_JNI_LIBS:= \
@lib/armeabi/libcom_iflytek_inputmethod_mmp.so \
@lib/armeabi/libdexopt.so \
@lib/armeabi/libmsc-v8.so \
@lib/armeabi/libNativeCrashCollect.so \
@lib/armeabi/libsmartaiwrite-jni-v22.so \
@lib/armeabi/libvadLib-v5.so \
@lib/armeabi/libwatchdog.so
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_PRIVILEGED_MODULE := true
include $(BUILD_PREBUILT)
需要注意的是,如果这个apk带有so文件。需要将lib/arm下的so文件按照LOCAL_PREBUILT_JNI_LIBS:= \
@lib/armeabi/libcom_iflytek_inputmethod_mmp.so
这样的格式来写。参考链接
作者:u013377887 发表于2016/12/25 17:10:48 原文链接
阅读:72 评论:0 查看评论