Adding a link to an external bank in Android.mk

I want to add an external third-party jar file to the embedded Android application.

I added the LOCAL_CLASSPATH variable to Android.mk, due to which the compilation went fine. But at runtime, it cannot find the class definition that is in the JAR.

What variable do I need to set to add third-party JARs in .dex / .apk?

TIA.

+6
android
source share
5 answers

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 to Android.mk after include $(BUILD_PACKAGE)

You also need to specify the library name in LOCAL_STATIC_JAVA_LIBRARIES to compile.

+12
source share

An example is more than just a conversation.

 ... 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 "mylib.jar" in the root directory of the project.

+15
source share

Add it using the flags LOCAL_STATIC_JAVA_LIBRARIES and LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES .

and put LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES between include $(BUILD_PACKAGE) and turn on $(BUILD_MULTI_PREBUILT) .

Everything will be fine. thanks for the provided a2ronus URL.

0
source share
 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) 
0
source share

In Eclipse, select change the build path and select add an external jar and select the jar that you want to include.

-2
source share

All Articles