Tian haili @ csdn
2012-08-28
Third-party software packages may be used in Android, including Java package. jar and native package. So. The jar package can be integrated through the eclipse development environment or by compiling the source code to view your work environment.
Assume that the program you develop is mymaps, and you need to use the baidumaps library, including baidumapapi. jar and libbmapapiengine_v1_3_1.so.
1. integrate third-party jar packages and. So dynamic libraries in eclipse
Create the libs and libs/armeabi directories in the mymaps project, put baidumapapi. jar in the libs/directory, and put libbmapapiengine_v1_3_1.so in libs/armeabi.
To package the third-party jar package baidumapapi. jar to mymaps in Eclipse:
1. Right-click the project and select Properties;
2. Select libraries for Java build path;
3. Click "add Library…" on the right of the Libraries page ...";
4. Select "User library" and click "Next ";
5. Click "User libraries;
6. Click "new..." in the pop-up interface ...";
7. Enter "User library name" and click "OK;
8. Select the user library you just created and click "addjars" on the right ";
9. Select baidumapapi. Jar under mymaps/libs;
10. Confirm and return.
In this way,After compilationThe jar package will be pushed to mymaps.apk, and libbmapapiengine_v1_3_1.so will also be packaged in lib/armeabi.
Running, Libbmapapiengine_v1_3_1.so is put under/data/<yourapppackage>/lib/. When loading a dynamic library, the system will find the. So library in the LIB/directory of the program.
2. integrate third-party integrated jar package and. So dynamic library in source code
Put mymaps In the android source code under packages/apps. Create the libs and libs/armeabi directories under mymaps, put baidumapapi. jar in libs/, and put libbmapapiengine_v1_3_1.so in libs/armeabi.
2.1 modify the Android. mk File
The android. mk file is as follows:
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_STATIC_JAVA_LIBRARIES := libbaidumapapi LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := MyMaps include $(BUILD_PACKAGE) ##################################################include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES :=libbaidumapapi:libs/baidumapapi.jarLOCAL_PREBUILT_LIBS :=libBMapApiEngine_v1_3_1:libs/armeabi/libBMapApiEngine_v1_3_1.soLOCAL_MODULE_TAGS := optionalinclude $(BUILD_MULTI_PREBUILT) # Use the following include to make our testapk.include $(callall-makefiles-under,$(LOCAL_PATH))
1. Integrate the jar package
Local_static_java_librariesTake the alias of the jar library, which can be any value;
Local_prebuilt_static_java_librariesSpecifies the prebuiltjar library rule. Format: alias: JAR file path. Note: The alias must be the same as the alias obtained in local_static_java_libraries without. Jar. the JAR file path must be the path that stores the third-party jar package.
CompilationBuild_multi_prebuilt.
2. Integrate the. So dynamic library
Local_prebuilt_libs specifies the prebuilt so rule. Format: alias: So file path. Note: aliases are generally unchangeable, especially when third-party jar packages use the. So library, and do not include. So; so file paths must be real paths for storing third-party so files.
For compiling and copyingBuild_multi_prebuilt.
2.2 add to grandfathered_user_modules
In the user_tags.mk file, add libbmapapiengine_v1_3_1 to grandfathered_user_modules.
GRANDFATHERED_USER_MODULES += \ … \ libBMapApiEngine_v1_3_1
User_tags.mk can be in build/core or $ (target_device_dir). We recommend that you modify $ (target_device_dir.
2.3 compilation result
The compilation of mymaps.apk is generated under out/target/product/<yourproduct>/system/APP;
Libbmapapiengine_v1_3_1.so is stored in the out/target/product/<yourproduct>/system/lib/directory, which is also the path searched when the system loads the dynamic library.