android编译dex-preopt
来源:互联网 发布:美国车价 知乎 编辑:程序博客网 时间:2024/06/18 11:38
$ cat buildspec.mk
TARGET_BUILD_VARIANT:=user
TARGET_BUILD_TYPE:=release
编译相关文件:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
build/core/product_config.mk:164
# Hack to make the linux build servers use dexpreopt (emulator-based
# preoptimization). Most engineers don't use this type of target
# ("make PRODUCT-blah-user"), so this should only tend to happen when
# using buildbot.
# TODO: Remove this once host Dalvik preoptimization is working.
ifeq ($(TARGET_BUILD_VARIANT),user)
WITH_DEXPREOPT_buildbot := true
endif
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
build/core/dex_preopt.mk:127
# dexpreoption for binary released jars
# ONLY enabled in custom release
ifeq ($(PARTIAL_BUILD),true)
ifeq ($(WITH_DEXPREOPT),true)
$(foreach m,$(DEXPREOPT_BINARY_RELEASE_BOOT_JARS_MODULES), \
$(eval $(call install-dexpreopt-jars.binary-release,$(m))) \
$(eval DEXPREOPT_BINARY_RELEASE_BOOT_JARS += \
$(TARGET_OUT_JAVA_LIBRARIES)/$(m).jar \
$(TARGET_OUT_JAVA_LIBRARIES)/$(m).odex \
) \
)
endif
endif
# $(1): the input .jar or .apk file
# $(2): the output .odex file
define dexpreopt-one-file
$(hide) $(DEXPREOPT) --dexopt=$(DEXPREOPT_DEXOPT) --build-dir=$(DEXPREOPT_BUILD_DIR) \
--product-dir=$(DEXPREOPT_PRODUCT_DIR) --boot-dir=$(DEXPREOPT_BOOT_JAR_DIR) \
--boot-jars=$(DEXPREOPT_BOOT_JARS) $(DEXPREOPT_UNIPROCESSOR) \
$(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(1)) \
$(patsubst $(DEXPREOPT_BUILD_DIR)/%,%,$(2))
endef
调用于:
build/core/dex_preopt.mk:111: $$(call dexpreopt-one-file,$$(PRIVATE_DBJ_JAR),$$@)
build/core/package.mk:440: $(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
build/core/java_library.mk:121: $(call dexpreopt-one-file,$<,$@)
build/core/prebuilt.mk:82: $(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
build/core/package.mk:216
ifeq (true,$(WITH_DEXPREOPT))
ifeq (,$(TARGET_BUILD_APPS))
ifneq (,$(LOCAL_SRC_FILES))
ifndef LOCAL_DEX_PREOPT
LOCAL_DEX_PREOPT := true
endif
endif
endif
endif
实际编译时对生成apk的地方:
# Define the rule to build the actual package.
$(LOCAL_BUILT_MODULE): $(AAPT) | $(ZIPALIGN)
ifeq ($(LOCAL_DEX_PREOPT),true)
# Make sure the boot jars get dexpreopt-ed first
$(LOCAL_BUILT_MODULE): $(DEXPREOPT_BOOT_ODEXS) | $(DEXPREOPT) $(DEXOPT)
endif
$(LOCAL_BUILT_MODULE): PRIVATE_JNI_SHARED_LIBRARIES := $(jni_shared_libraries)
ifneq ($(TARGET_BUILD_APPS),)
# Include all resources for unbundled apps.
$(LOCAL_BUILT_MODULE): PRODUCT_AAPT_CONFIG :=
endif
$(LOCAL_BUILT_MODULE): $(all_res_assets) $(jni_shared_libraries) $(full_android_manifest)
@echo "target Package: $(PRIVATE_MODULE) ($@)"
$(create-empty-package)
$(add-assets-to-package)
ifneq ($(jni_shared_libraries),)
$(add-jni-shared-libs-to-package)
endif
ifneq ($(full_classes_jar),)
$(add-dex-to-package)
endif
$(sign-package) // apk签名
@# Alignment must happen after all other zip operations.
$(align-package)
ifeq ($(LOCAL_DEX_PREOPT),true)// 对apk进行dexpreopt,定义于build/core/dex_preopt.mk
$(hide) rm -f $(patsubst %.apk,%.odex,$@)
$(call dexpreopt-one-file,$@,$(patsubst %.apk,%.odex,$@))
$(call dexpreopt-remove-classes.dex,$@)
built_odex := $(basename $(LOCAL_BUILT_MODULE)).odex
$(built_odex): $(LOCAL_BUILT_MODULE)
endif
apk签名函数定义于文件:build/core/definitions.mk +1456
# Sign a package using the specified key/cert.
#
define sign-package
$(hide) mv $@ $@.unsigned
$(hide) java -jar $(SIGNAPK_JAR) \
$(PRIVATE_CERTIFICATE) $(PRIVATE_PRIVATE_KEY) $@.unsigned $@.signed
$(hide) mv $@.signed $@
endef
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
./core/main.mk:183: WITH_DEXPREOPT := true
./core/main.mk:246: WITH_DEXPREOPT := true
./core/main.mk:252: ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
./core/main.mk:253: WITH_DEXPREOPT := true
183
ifeq (user, $(TARGET_BUILD_VARIANT))
WITH_DEXPREOPT := true
endif
# Bring in dex_preopt.mk
include $(BUILD_SYSTEM)/dex_preopt.mk
246
user_variant := $(filter userdebug user,$(TARGET_BUILD_VARIANT))
enable_target_debugging := true
ifneq (,$(user_variant))
...
# enable dex pre-optimization for all TARGET projects in default to
# speed up device first boot-up
WITH_DEXPREOPT := true
...
# TODO: Remove this and the corresponding block in
# config/product_config.make once host-based Dalvik preoptimization is
# working.
ifneq (true,$(DISABLE_DEXPREOPT))
ifeq ($(HOST_OS)-$(WITH_DEXPREOPT_buildbot),linux-true)
WITH_DEXPREOPT := true
endif
endif
...
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
build/core/java_library.mk +68
ifeq (true,$(WITH_DEXPREOPT))
ifeq (,$(TARGET_BUILD_APPS))
ifndef LOCAL_DEX_PREOPT
LOCAL_DEX_PREOPT := true
endif
endif
endif
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
build/core/java_library.mk +68
ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
ifeq (true,$(WITH_DEXPREOPT))
ifeq (,$(TARGET_BUILD_APPS))
ifndef LOCAL_DEX_PREOPT
LOCAL_DEX_PREOPT := true
endif
endif
endif
endif
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- android编译dex-preopt
- dex-preopt,使用方法
- android2.3对dex进行preopt优化
- android 编译:classes-with-local.dex] Killed
- android 编译:classes-with-local.dex] Killed
- android eclipse 编译时dex重复
- 编译错误:com.android.dex.DexException:
- Android编译及Dex过程源码分析
- Android Studio 编译报错com.android.dex.DexException: Multiple dex files define La/We
- Android Studio 编译报错 Error:Error converting bytecode to dex: Cause: com.android.dex.DexIndexOverflowE
- Android编译时出现"Unable to execute dex: Multiple dex files define Lcom..."
- Android 程序编译问题Unable to execute dex: Multiple dex files define
- 编译Android出错:Unable to execute dex: Java heap space
- Android APK+Dex文件反编译及回编译工具
- 编译Android出错:Unable to execute dex: Java heap space .
- 编译Android出错:Unable to execute dex: Java heap space
- 编译Android出错:Unable to execute dex: Java heap space
- 编译android源码出错noproguard.classes-with-local.dex
- Oracle中start with...connect by子句的用法
- 向android模拟器更换系统APK
- Java多线程编程总结
- chrome浏览器及flash插件
- 用C设计,用C++编码
- android编译dex-preopt
- 未来的游戏盈利方式
- poj3261
- MT6573 android2.3.4 OTA包的生成研究
- android 学习基础篇---开发环境的搭建 Eclipse SDK jdk ADT
- PHP获取客户端、PHP获取服务器相关信息
- 全局监听SCREEN_ON和SCREEN_OFF的替代方法--监听屏幕解锁事件
- Chrome源码剖析【二】
- IOS 不让键盘挡住UITextField (自适应)