Android -- 源码平台下JAR包的引入与编译
https://blog.csdn.net/csdn_of_coder/article/details/64538227
BUILD_JAVA_LIBRARY 与 BUILD_STATIC_JAVA_LIBRARY
在Android.mk中可通过调用include $(BUILD_JAVA_LIBRARY)和include $(BUILD_STATIC_JAVA_LIBRARY)来分别生成目标设备上的共享JAVA库与静态JAVA库。
二者的区别在于静态JAVA库是由.class文件打包而成JAR包,它在任何一个JAVA虚拟机上都可以运行;而共享JAVA库则是在静态库的基础上进一步打包成的.dex文件,众所周知,dex是在android系统上所使用的文件格式。
由以上结论可做出进一步的推论:即Android.mk中变量LOCAL_JAVA_LIBRARIES所指定的为android系统使用的dex类库;而LOCAL_STATIC_JAVA_LIBRARIES变量所指定的则是.class文件打包而成的JAR文件:即静态JAVA库。
BUILD_STATIC_JAVA_LIBRARY会生成out/target/common/obj/JAVA_LIBRARIES/appsaut_intermediates目录及其下的JAR文件;而BUILD_JAVA_LIBRARY生成此目录的同时会将其中的JAR包复制到out/target/product/<product-name>/system/framework/中;除此之外,还存在BUILD_HOST_JAVA_LIBRARY命令则是在out/host/linux-x86/framework目录下生成相应的JAR包。分别使用此三条命令执行的结果如下所示:注意其中带有红色下划线的LOG信息。
Basic usage:
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := app_sdk_data.jar \
bsh-core-2.0b4.jar \
jackson-annotations-2.0.2.jar \
jackson-core-2.0.2.jar \
jackson-databind-2.0.2.jar \
kksdk1.3_full_pro.jar
include $(BUILD_MULTI_PREBUILT)
////////////////////////////////////////////////////////////////////////////
LOCAL_STATIC_JAVA_LIBRARIES := appsaut
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := appsaut:libs/appsaut.jar
include $(BUILD_MULTI_PREBUILT)
android 源码中mmm依赖第三方jar包的项目
https://my.oschina.net/blackylin/blog/109527
在项目根目录下的Android.mk中:
1.
LOCAL_STATIC_JAVA_LIBRARIES := libGoogleAnalytics libGoogleAdMobAdsSdk libmobclix
2.
################################################## include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libGoogleAnalytics:libs/libGoogleAnalytics.jar include $(BUILD_MULTI_PREBUILT) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libGoogleAdMobAdsSdk:libs/GoogleAdMobAdsSdk-4.1.1.jar include $(BUILD_MULTI_PREBUILT) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libmobclix:libs/mobclix.jar include $(BUILD_MULTI_PREBUILT)
把依赖的jar包放到libs目录下,先预编译到out/target/product/generic/obj/JAVA_LIBRARIES下,然后本项目就会找到依赖的者jar包了。下面完整Andraoid.mk如下:
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional # Only compile source java files in this apk. LOCAL_SRC_FILES := $(call all-java-files-under, src) LOCAL_PACKAGE_NAME := DependJarTest LOCAL_CERTIFICATE := platform LOCAL_STATIC_JAVA_LIBRARIES := libGoogleAnalytics libGoogleAdMobAdsSdk libmobclix include $(BUILD_PACKAGE) ################################################## include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libGoogleAnalytics:libs/libGoogleAnalytics.jar include $(BUILD_MULTI_PREBUILT) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libGoogleAdMobAdsSdk:libs/GoogleAdMobAdsSdk-4.1.1.jar include $(BUILD_MULTI_PREBUILT) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libmobclix:libs/mobclix.jar include $(BUILD_MULTI_PREBUILT) # Use the folloing include to make our test apk. include $(call all-makefiles-under,$(LOCAL_PATH))
Android FrameWork集成第三方SDK的jar包和so库
https://blog.csdn.net/szqsdq/article/details/53035460
首先在framework/opt/建立XXSDK的文件夹讲jar包和so库拷贝进去
1:framework/opt/xxsdk/
然后直接看Android.mk就行
# Copyright (C) 2009 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 := $(my-dir) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := app_sdk_data.jar bsh-core-2.0b4.jar jackson-annotations-2.0.2.jar jackson-core-2.0.2.jar jackson-databind-2.0.2.jar kksdk1.3_full_pro.jar include $(BUILD_MULTI_PREBUILT) ################################################## include $(CLEAR_VARS) LOCAL_MODULE := libcode LOCAL_SRC_FILES := libs/libcode.so LOCAL_MODULE_SUFFIX := .so LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_PREBUILT) include $(call all-makefiles-under,$(LOCAL_PATH)) ################################################## include $(CLEAR_VARS) LOCAL_MODULE := libluajava LOCAL_SRC_FILES := libs/libluajava.so LOCAL_MODULE_SUFFIX := .so LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_PREBUILT) include $(call all-makefiles-under,$(LOCAL_PATH)) ################################################## include $(CLEAR_VARS) LOCAL_MODULE := libtruss LOCAL_SRC_FILES := libs/libtruss.so LOCAL_MODULE_SUFFIX := .so LOCAL_MODULE_CLASS := SHARED_LIBRARIES include $(BUILD_PREBUILT) include $(call all-makefiles-under,$(LOCAL_PATH))