开发者

Adding a external jar reference in Android.mk

I want to add a external third party jar file in the inbuilt android app.

I've added the LOCAL_CLASSPATH variable in Android开发者_运维技巧.mk due to which the compilation goes fine. But during runtime, it is not able to find the class definiation which is in the JAR.

Which is the variable I need to set to add the third party JARs in the .dex/.apk ?

TIA.


An example is more than just talking.

...

LOCAL_STATIC_JAVA_LIBRARIES := libmylibs

LOCAL_PACKAGE_NAME := myapp

...

include $(BUILD_PACKAGE)

##################################################
include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := libmylibs:mylib.jar

include $(BUILD_MULTI_PREBUILT)

Note: put the "mylib.jar" at the project root.


Here is what I used to solve the problem :

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := path_to_jar_file.jar
include $(BUILD_MULTI_PREBUILT)

This should be added in Android.mk after include $(BUILD_PACKAGE)

You also need to specify the library name in LOCAL_STATIC_JAVA_LIBRARIES for compilation.


Add it with LOCAL_STATIC_JAVA_LIBRARIES & LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES flag.

and put LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES between include $(BUILD_PACKAGE) & include $(BUILD_MULTI_PREBUILT).

It will OK. thanks for the URL a2ronus provided.


LOCAL_STATIC_JAVA_LIBRARIES := \
other libs \
your_jar

include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := your_jar:jar_path/jar_file.jar
include $(BUILD_MULTI_PREBUILT)


In Eclipse choose modify build path and choose add external jar, and select the jar you watn to include.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜