Compile the operation of specifying jar package in Android source code

  • 2021-11-24 02:54:25
  • OfStack

Today, I want to compile the source code under android source code/vendor/letv/frameworks/base/java into framework-letv. jar for Lele voice client. After compiling, I found that although jar package file was generated, there was no related source code class file in the package, which could not be used normally.

After consultation and research, it is found that the following options need to be added to Android. mk file:


 54 LOCAL_JACK_ENABLED := disabled # important!
 55 #include $(BUILD_JAVA_LIBRARY) 

 56 include $(BUILD_STATIC_JAVA_LIBRARY) # Compile jar Bag 

Finally, javalib. jar is generated, which can be renamed framework-letv. jar. Note: If the LACAL_JACK_ENABLED option is not specified, the default is enabled and the classes. jack file will be generated instead of the classes. jar package!

Additional points: In a 1 application sometimes need to reference the third-party jar package, so how can you compile the app when the jar package into?

Add the following statement to the Android. mk file under the app:


LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := user eng
########################################
LOCAL_STATIC_JAVA_LIBRARIES := lib3party // Define reference name 
########################################
....
include $(BUILD_PACKAGE)
###############################################################
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := lib3part:libs/3part.jar // Reference name: jar Package name 
include $(BUILD_MULTI_PREBUILT)
################################################################ 

Add jar package, the key is LOCAL_STATIC_JAVA_LIBRARIES: = libarity and LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES: = libarity: lily. jar.

libarity is the alias of jar package, which can be taken casually, as long as it corresponds to the following. But the jar package name after the colon must be written with the jar package name you need to introduce.

The jar package should be placed in the root directory of the project, which is the same directory as the src, res, Android. mk files of the app you want to compile.


Related articles: