Android P去掉DEX优化编译

Android P的系统编译中,采用了DEX优化编译。

单个apk或者jar去Dex编译

在系统中编译出来的文件如下:
oat
-arm64
-SystemUI.odex
-SystemUI.vdex
SystemUI.apk

生成了后缀为odex和vdex的文件,在调式过程中,可能会出现问题。

去掉DEX优化编译的方法:
1、mm WITH_DEXPREOPT=false
2、Android.mk中增加:LOCAL_DEX_PREOPT := false

整个系统去DEX编译

make -j8 WITH_DEXPREOPT=false
报错:

ninja: no work to do.
[1/1] out/soong/.bootstrap/bin/soong_build out/soong/build.ninja
No need to regenerate ninja file
Environment variable WITH_DEXPREOPT was set, regenerating...
: error: : DEXPREOPT must be enabled for user and userdebug builds
build/make/core/dex_preopt.mk:55: error: done.
09:51:08 ckati failed with: exit status 1

修改build/make/core/dex_preopt.mk

  # Non eng linux builds must have preopt enabled so that system server doesn't run as interpreter
  # only. b/74209329
  ifeq (,$(filter eng, $(TARGET_BUILD_VARIANT)))
    ifneq (true,$(WITH_DEXPREOPT))
      ifneq (true,$(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY))
        $(call pretty-error, DEXPREOPT must be enabled for user and userdebug builds)
      endif
    endif
  endif

将ifneq (true, ( W I T H D E X P R E O P T ) ) 改 为 i f e q ( t r u e , (WITH_DEXPREOPT))改为ifeq (true, (WITHDEXPREOPT))ifeq(true,(WITH_DEXPREOPT))或者ifneq (false,$(WITH_DEXPREOPT))
因为默认eng编译,WITH_DEXPREOPT必须打开为true,否则提示编译报错。

即:非英文linux构建必须已启用preopt,以便系统服务器不会仅作为解释器运行。

你可能感兴趣的:(Android,系统)