How Android uses jar packages instead of Java code compilation

Source: Internet
Author: User

1. First complete the project (any eng/user), then save the jar package to replace the JAVA code, in the Alps/out/target/common/obj/java_libraries/xxx__intermediates directory
Classes.jar
Javalib.jar

2. Please save the following files to Java_library_prebuilt.mk and place them under the Alps/build/core/directory:
Note: There are 11 places to start the TAB key (make syntax for the command to start the TAB key, but the site does not support the TAB key), save as a file after you open the edit, 11 (the following flag) to re-tab key processing again.
##
Local_src_files: =
Ifdef local_is_host_module
$ (Error $ (local_path): Just for Target Java library)
endif
Local_module_suffix: = $ (Common_java_package_suffix)
Local_module_class: = java_libraries
Local_built_module_stem: = Javalib.jar
Intermediates.common: = $ (call Local-intermediates-dir,common)
Full_classes_jar: = $ (Intermediates.common)/classes.jar
Common_javalib.jar: = $ (Intermediates.common)/$ (Local_built_module_stem)
Local_intermediate_targets + = $ (Full_classes_jar) $ (Common_javalib.jar)
Ifneq (true,$ (with_dexpreopt))
Local_dex_preopt: =
Else
Ifeq (, $ (Target_build_apps))
Ifndef local_dex_preopt
Local_dex_preopt: = True
endif
endif
endif
Ifeq (false,$ (local_dex_preopt))
Local_dex_preopt: =
endif
Include $ (build_system)/base_rules.mk
$ (Cleantarget): Private_clean_files + + $ (intermediates.common)
$ (Full_classes_jar): $ (local_path)/classes.jar | $ (ACP)
$ (call Copy-file-to-target) #注意: This must start with the TAB key
$ (Common_javalib.jar): $ (Local_path)/$ (Local_built_module_stem) | $ (Full_classes_jar) $ (ACP)
$ (call Copy-file-to-target) #注意: This must start with the TAB key
Ifdef local_dex_preopt
Dexpreopt_boot_jar_module: = $ (Filter $ (local_module), $ (dexpreopt_boot_jars_modules))
Ifneq ($ (dexpreopt_boot_jar_module),)
Dexpreopted_boot_jar: = $ (Dexpreopt_boot_jar_dir_full_path)/$ (dexpreopt_boot_jar_module) _nodex.jar
$ (Local_built_module): $ (Dexpreopted_boot_jar) | $ (ACP)
$ (call Copy-file-to-target) #注意: This must start with the TAB key
Dexpreopted_boot_odex: = $ (Dexpreopt_boot_jar_dir_full_path)/$ (dexpreopt_boot_jar_module). Odex
Built_odex: = $ (basename $ (local_built_module)). Odex
$ (Built_odex): $ (Dexpreopted_boot_odex) | $ (ACP)
$ (call Copy-file-to-target) #注意: This must start with the TAB key
Else
Built_odex: = $ (basename $ (local_built_module)). Odex
$ (Built_odex): Private_module: = $ (Local_module)
$ (Built_odex): $ (DEXPREOPT_BOOT_ODEXS)
$ (Built_odex): $ (Common_javalib.jar) | $ (dexpreopt) $ (dexopt)
@echo "Dexpreopt Jar: $ (private_module) ([email protected]) #注意: This must start with the TAB key
$ (hide) rm-f [email protected] #注意: This must start with the TAB key
@mkdir-P $ (dir [email protected]) #注意: This must start with the TAB key
$ (call Dexpreopt-one-file,$<,[email protected]) #注意: This must start with the TAB key
$ (Local_built_module): $ (Common_javalib.jar) | $ (ACP) $ (AAPT)
$ (call Copy-file-to-target) #注意: This must start with the TAB key
Ifneq (nostripping,$ (local_dex_preopt))
$ (call Dexpreopt-remove-classes.dex,[email protected]) #注意: This must start with the TAB key
endif
endif
Else
$ (Local_built_module): $ (Common_javalib.jar) | $ (ACP)
$ (call Copy-file-to-target) #注意: This must start with the TAB key
endif

3. Add in Alps/build/core/config.mk:
Build_java_library_prebuilt:= $ (Build_system)/java_library_prebuilt.mk

4. Delete the corresponding Java code and the corresponding android.mk, then create a new android.mk in the current directory, and copy the 1th step back up the 2 files to android.mk (note that the file name can not be modified, otherwise unrecognized!!!), The new android.mk is written as follows:
Local_path: = $ (call My-dir)
Include $ (clear_vars)
Local_module: = Services
Local_module_path: = $ (target_out_java_libraries)
Include $ (build_java_library_prebuilt)

5. Re-complete the compilation project (any eng/user), download the View effect

6. Important note, because the 1th step save Classes.jar is not through proguard, outflow to easily be anti-compilation, please do Proguard, but please do not put the interface Proguard, or compile failed!

How Android uses jar packages instead of Java code compilation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.