android编译自己 内置的jar做法

   1.首先 android.mk

LOCAL_PATH := $(call my-dir)
# ============================================================
include $(CLEAR_VARS)


LOCAL_SRC_FILES :=  java/com/xxx/xxx/xxx.java \

                                            java/com/xxx/xxx/xxx2.java 
                    


LOCAL_NO_STANDARD_LIBRARIES := true
LOCAL_JAVA_LIBRARIES := core framework
LOCAL_MODULE_TAGS := eng
LOCAL_MODULE:= test
LOCAL_DX_FLAGS := --core-library

include $(BUILD_JAVA_LIBRARY)


# this is will add the test.xml  
#===============================================================
include $(CLEAR_VARS)
LOCAL_MODULE := test.xml
LOCAL_MODULE_CLASS := ETC
# This will install the file in /system/etc/permissions
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/permissions
LOCAL_SRC_FILES := $(LOCAL_MODULE)
include $(BUILD_PREBUILT)

include $(call all-makefiles-under,$(LOCAL_PATH))

2.test.xml 内容

<permissions>
    <library name="yecon" file="/system/framework/yecon190.jar"/>
</permissions>

3.makesdk.sh

#!/bin/sh
if [ -d $xxx_DIR -a -d $ANDROID4 ]; then
echo "xxx_DIR is : $xxx_DIR"
MANIFEST_FILE=$xxx_DIR/frameworks/xxx/core/MANIFEST.MF
xxxx_SRC_FILE=$ANDROID4/out/target/common/obj/JAVA_LIBRARIES/xxxxx_intermediates/classes
SDK_PATH=$ANDROID4/xxx/sdk
if [ -d $ATCJAR_FILE ];then
mkdir -p $SDK_PATH
chmod a+x $SDK_PATH
jar cvfm $SDK_PATH/yxxx.jar $MANIFEST_FILE -C $xxxx_SRC_FILE .
chmod a+x -R $SDK_PATH
else

echo "++++No such directory: $xxxx_SRC_FILE!+++++"
fi
else
echo "xxx or Android dir not set"
echo "please run command : source ./selfenv bootmedia"
echo "e.g. source ./selfenv sd2"
fi

4.MANIFEST.MF

Manifest-Version: 1.0
Created-By: yecon
Specification-Vender: yecon
Specification-Version: 1.0.0


5.然后将  xxxx 与 xxx.xml 放入系统配置中编译   PACKAGE=  XXXX   \

                                                                                                           xxxx.xml 

6. 在init.rc 中加入

BOOTCLASSPATH     " :/system/framework/xxxx.jar  "

7.应用或者其他jar中调用

LOCAL_STATIC_JAVA_LIBRARIES :=   xxxxx

或者 

LOCAL_JAVA_LIBRARIES :=   xxxxx




郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。