Dear friends, you may encounter problems such as the title.
I wrote an android project using Eclipse, but this project requires a hidden class of the SDK. All the classes that I want to compile under the source code will encounter errors after each mm, the prompt is that the corresponding class cannot be found.
The four jar packages that I need to add are as follows:
Org. apache. commons. codec-1.7.0.jar
Org. knopflerfish. bundle. kxml-LIB-2.3.0.jar
Osgi. cmpn-4.3.0.jar
Osgi. core-4.3.0.jar
I hope you will make great moves. Younger brother online...
After last night's research, I finally found a solution, because I did not write the Android. mk file before, so I don't know how to load the jar package.
To compile the android project in the source code to use a third-party jar package, you must add the java static library directory to the Android. mk file. Two variables in the Android. mk file are used.
LOCAL_STATIC_JAVA_LIBRARIES and LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES are static libraries to be loaded. Here I paste my Android. mk File
Android. mk
LOCAL_PATH:= $(call my-dir)include $(CLEAR_VARS)LOCAL_MODULE_TAGS := optionalLOCAL_SRC_FILES := $(call all-java-files-under, src)# Added for source code compile start LOCAL_STATIC_JAVA_LIBRARIES := jarlib1 jarlib2 jarlib3 jarlib4LOCAL_PACKAGE_NAME := yourprojectname# Added for source code compile endLOCAL_CERTIFICATE := platforminclude $(BUILD_PACKAGE)# Added for source code compile start include $(CLEAR_VARS)LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := jarlib1:jars/org.apache.commons.codec-1.7.0.jar jarlib2:jars/org.knopflerfish.bundle.kxml-LIB-2.3.0.jar jarlib3:jars/osgi.cmpn-4.3.0.jar jarlib4:jars/osgi.core-4.3.0.jarinclude $(BUILD_MULTI_PREBUILT)# Added for source code compile end# Use the folloing include to make our test apk.include $(call all-makefiles-under,$(LOCAL_PATH))
There are two problems:
1. Where is the jar file stored in the android project?
The answer is wherever you are! For example, if I put it under the jars folder in the main directory of the project, I need to specify a path when defining the value of LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES, that is, jars /.
Second, how do I reference the mk file?
We can see that the mk file has two more variables than the average mk file.
The first LOCAL_STATIC_JAVA_LIBRARIES is the java static library. Here we only need to get a name. The library file corresponding to the specific library needs to be loaded in LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES. For how to write the value of LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES, see the prompt in the mk file.
When you are a beginner in android source code compilation, you may encounter many problems.