软件平台:Android8.1
硬件平台:展讯
近日,在做将我们自己的java源码以sdk的形式移植至系统的工作,要求编译生成可用的jar包,提供给app使用。
首先我们依赖的第三方的jar包,独立编译:
mk如下:
LOCAL_PATH:= $(call my-dir)
$(warning "coming to $(LOCAL_PATH)")
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := exoplayer:exoplayer-core-2.9.1.jar
include $(BUILD_MULTI_PREBUILT)
其次我们的src编译
# Copyright (C) 2014 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
LOCAL_PATH := $(call my-dir)
$(warning "coming to $(LOCAL_PATH)")
# Build the java code
# ============================================================
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
#LOCAL_JACK_ENABLED := disabled
ANDROID_COMPILE_WITH_JACK := disabled
LOCAL_STATIC_JAVA_LIBRARIES := exoplayer
src_dirs := \
lib_app \
lib_common
LOCAL_SRC_FILES := $(call all-java-files-under,$(src_dirs))
$(warning "src files: $(LOCAL_SRC_FILES)")
LOCAL_MODULE :=iflyplayer
#include $(BUILD_JAVA_LIBRARY)
include $(BUILD_STATIC_JAVA_LIBRARY)
#include $(CLEAR_VARS)
#LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := exoplayer:../common_libs/exoplayer-core-2.9.1.jar
#include $(BUILD_MULTI_PREBUILT)
#include $(BUILD_PREBUILT)
#include $(call all-makefiles-under,$(LOCAL_PATH))
编译完成,在out目录生成相应的classes.jar,注意里边的JACK选项,该选项禁用掉,生成的jar包才是各个.class文件的组合包。
以上完成之后,仅仅是在obj目录有相应的jar生成,确没有在system/framework目录生成,需要做如下改动:
在device目录的DeviceCommon.mk中添加:
# iflytek add sdk package
PRODUCT_PACKAGES += \
iflyplayer
PRODUCT_BOOT_JARS := \
iflyplayer
同时还要添加bootjar白名单文件build/make/core/tasks/check_boot_jars/package_whitelist.txt:
com\.player\.lib_app
com\.player\.lib_app\..*
lib_common
lib_common\..*
大功告成!导入测试使用。