Steps:
Method 1:eclipse,
Right-click Project, build path, Java build path,
Select Libraries Click "Add Library" on the right button to select "User Library",
Click "Next" and click "User Librarys" button to click "New" in the interface that appears. button to make a name in the popup screen, click "OK"
Click on the "Add jars" button to select the third party jar package and click "OK" to finish.
The following steps are important if you do not perform the subsequent operations.
In eclipse, there is no error in displaying the compile pass, but there may be errors such as java.lang.noclassdeffounderror when running on the emulator or on the real machine:
1. Create a new Libs folder in the root directory of the Android project;
2. Copy the imported third-party jar package you need into this directory;
3, right click on the Libs directory, select Bulid path–> use as source folder.
Method 2,android the source environment,
1, put the Classess.jar file under the out/target/common/obj/java_libraries/powersave_intermediates in its own project directory. Jar packages under the Out/target/product/ventana/system/framework directory the following methods are not proven to work, as he has already played the Dex file and it is not possible to quote his package in the project;
2. Modify the Android.mk file as follows:
Local_path:= $ (call My-dir) include $ (clear_vars)
Local_module_tags: = Optional
Local_src_files: = $ (call All-java-files-under, SRC)
Local_static_java_libraries: = Libpowerjar libpowersave
Local_package_name: = Testpowerjar
Local_certificate: = Platform
Include $ (build_package) ############################################## include $ (clear_vars)
Local_prebuilt_static_java_libraries: = Libpowerjar:classes.jar Libpowersave:testlily.jar include $ (build_multi_ prebuilt)
# Use the folloing include to make our test apk. Include $ (call all-makefiles-under,$ (Local_path))
Explanation: Local_static_java_libraries: =libpowerjar and local_prebuilt_static_java_libraries: =libpowerjar: Classes.jar actually libarity is a name can be arbitrarily taken, two attributes of the value of the same as good, but the next colon inside must write your jar package name, your jar package must be placed in the root directory of the project is good. Here is an example of using a two jar package.
3, the source directory compiled can: # mmm Package/app/testpowerjar, if the error indicates that the package can not find the jar, then please #touchclasses.jar.
To generate a jar package:
Method 1:eclipse, 1. Create Java or Android project; 2. Add Android.jar 3 to the project Properties Java build path->libraries. Right-click Project in Package Explorer, export Java->jar file.
Method 2:android the source environment
1. Modify the Android.mk file,
Local_path:= $ (call My-dir) # The Library # ============================================================ include $ ( Clear_vars)
Local_module_tags: = Optional Local_src_files: = Powersave.java local_module: = PowerSave
Include $ (build_java_library)
# Additionally, build unit tests in a separate APK include $ (call all-makefiles-under,$ (Local_path))
2, compiling # MMM PowerSave (own module)
Where build_java_library represents the build Jar package, where the package is placed in Out/target/product/ventana/system/framework and Out/target/common/obj/java_ Libraries/powersave_intermediates (own module),
Reference: http://blog.chinaunix.net/uid-26524139-id-3161858.html
Using third-party jar packages in Android