共享第三方jar java
兩種引用方法: android
1,AndroidManifest.xml express
<application
android:name="android.letvmedia.cts.MyApplication"
android:allowBackup="true"
android:debuggable="true" >
<uses-library android:name="myjar" /> apache
2,Android.mk
LOCAL_JAVA_LIBRARIES += myjar app
建立共享jar的方法: less
1, ui
aa.java :
/*************************************************************************
> File Name: aa.java
> Author:
> Mail:
> Created Time: Thu 24 Mar 2016 07:07:20 PM CST
************************************************************************/
class aa {
} this
2, debug
編譯出myjar.jar 相似framwork.jar xml
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