Karan Karan - 3 months ago 17
Android Question

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.

Answer

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.