共享第三方jar
两种引用方法:
1,AndroidManifest.xml
<application
android:name="android.letvmedia.cts.MyApplication" android:allowBackup="true" android:debuggable="true" > <uses-library android:name="myjar" />2,Android.mk
LOCAL_JAVA_LIBRARIES += myjar创建共享jar的方法:
1,
aa.java :
/************************************************************************* > File Name: aa.java > Author: > Mail: > Created Time: Thu 24 Mar 2016 07:07:20 PM CST ************************************************************************/ class aa { }2,
编译出myjar.jar 类似framwork.jar
Android.mk :
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES += \ myprebuild.jar #LOCAL_PREBUILT_LIBS += \ include $(BUILD_MULTI_PREBUILT) ########################################################################### include $(CLEAR_VARS) #LOCAL_SRC_FILES += \ # android/dolby/xxx.aidl \ # android/dolby/xxxxxxxx.aidl LOCAL_NO_STANDARD_LIBRARIES := true LOCAL_STATIC_JAVA_LIBRARIES := myprebuild LOCAL_SRC_FILES := ./aa.java LOCAL_MODULE_TAGS := optional LOCAL_MODULE := myjar1 LOCAL_MODULE_CLASS := JAVA_LIBRARIES LOCAL_NO_EMMA_INSTRUMENT := true LOCAL_NO_EMMA_COMPILE := true LOCAL_DX_FLAGS := --core-library #LOCAL_MODULE_OWNER := myname #LOCAL_SDK_VERSION := current include $(BUILD_JAVA_LIBRARY) #endif,3,
创建 myjar.xml指明jar包对应的存放路径。
<?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2008 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. --> <permissions> <library name="myjar" file="/system/framework/myjar1.jar" /> </permissions> 4,推配置文件myjar.xml 以及生成的myjar1.jar到相应的目录,使之可以被系统看见
可以执行下面的命令
adb root
adb remount echo "modify permission ,config library path doing" adb push myjar.xml /system/etc/permissions/ #echo "modify permission ,config library path done" echo "push myjar1.jar in" adb push myjar1.jar system/framework/ #echo "push myjar1.jar out" echo "adb reboot" adb reboot