Adding a jar file from libs/ to Android.mk

江枫思渺然 提交于 2019-12-02 16:26:14
Edward Falk

OK, a couple hours of googling and experimenting seems to have found the solution.
Documenting it here for others to find:

The key was to

  1. Define LOCAL_STATIC_JAVA_LIBRARIES with a symbolic name for the library I want to include, e.g. libjsch
  2. Execute CLEAR_VARS (why?)
  3. Define LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES as libjsch:<path-to-jar-file>
  4. Include BUILD_MULTI_PREBUILT.

(Testing showed that any symbolic name (e.g. "foo") works fine, as long as it matches in the two declarations.)

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

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := MyProject

LOCAL_STATIC_JAVA_LIBRARIES := libjsch

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libjsch:libs/jsch-0.1.49.jar

include $(BUILD_MULTI_PREBUILT)
Abhishek Dwarakanath

Thanks a ton Edward Falk. I have just resolved my problem with answer u have given me thanks again here is my code. The Keyword "lib" is a night mare.

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

LOCAL_MODULE_TAGS := optional

LOCAL_SRC_FILES := $(call all-subdir-java-files)

LOCAL_PACKAGE_NAME := MDM

LOCAL_STATIC_JAVA_LIBRARIES := libandroid-async-http libgcm libjson-simple


LOCAL_JAVA_LIBRARIES += telephony-common mms-common

LOCAL_CERTIFICATE := platform

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libandroid-async-http:libs/android-async-http-1.4.4.jar libgcm:libs/gcm.jar  libjson-simple:libs/json-simple-1.1.1.jar 

include $(BUILD_MULTI_PREBUILT)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!