Android编译选项eng、user、userdebug的区别

一、简要说明

1. eng user userdebug 定义

eng:debug 版本,又称工程版本;user: release 版本,又称发行版本;userDebug:部分调试版本


2. Android.mk 中的编译选项 LOCAL_MODULE_TAGS

Android源码编译选项eng、user、userdebug是由Android.mk文件中的 LOCAL_MODULE_TAGS 配置项来决定的。其一般形式如下:

LOCAL_MODULE_TAGS := user eng optional test

其设置为不同值是对应不同编译结果的:

user:只有在user版本时该模块才被编译进去;
eng:只有在eng版本时该模块才被编译进去;
test:只有在tests版本时该模块才被编译进去;
optional:在所有版本中都编译该模块进去。

其中的值可设置为1个或多个,分别对应编译选项的同一个或多个。


3. eng、user、userdebug的区别

(1) 当 make eng 时,也即相当于make。此时BuildType为eng,那么其编译进去的内容和设置包括:

· Intended for platform-level debugging
· Installs modules tagged with: eng, debug, user, and/or development
· Installs non-APK modules that have no tags specified
· Installs APKs according to the product definition files, in addition to tagged APKs
· Sets ro.secure=1
· Sets ro.debuggable=0
· Sets ro.kernel.android.checkjni=1
· adbd is enabled by default

(2) 当 make user 时,此时 BuildType 为 user,那么其编译进去的内容包括:

· Intended to be the final release
· Installs modules tagged as user
· Installs non-APK modules that have no tags specified
· Installs APKs according to the product definition files (tags are ignored for APK modules)
· Sets ro.secure=1
· Sets ro.debuggable=0
· adbd is disabled by default

(3) 当 make userdebug 时,此时 BuildType 为 userdebug,那么其编译进去的内容包括:

the same as user, except:
· Intended for limited debugging
· Installs modules tagged with debug
· Sets ro.debuggable=1
· adbd is enabled by default

 

二、对编译MTK版本的补充说明

1. debug log 方面

(1) 因user/eng 版本设置 ro.secure 不同,导致 user 版本 adb 只拥有 shell 权限,而 eng 版本具有 root 权限。
(2) MTK System LOG 在ICS 以后,在 user 版本默认关闭全部 LOG, 在 eng 版本中默认打开,以便抓到完整的资讯。
(3) 在 eng 版本上,LOG 量 >= user 版本的 log 量,一些地方会直接 check eng/user 版本来确认是否打印 LOG
(4) user 版本默认关闭 uart, eng 版本默认开启 uart
(5) 在 eng 版本上,开启 ANR 的 predump, 会抓取 ftrace,可以得到更多ANR的资讯。
(6) 在 eng 版本上,可用 rtt 抓取 backtrace,可开启 kdb 进行 kernel debug, 可用 ftrace 抓取 cpu 执行场景
(7) MTK aee 在 ENG 版本抓取更多的异常资讯,比如 native exception 会抓取 core dump 信息


2. 性能方面,原则上进行性能测试使用 user 版本

(1) user 版本为提高第一次开机速度,使用了 DVM 的预优化,将 dex 文件分解成可直接 load 运行的 odex 文件,ENG 版本不会开启这项优化.
(2) 更少的 LOG 打印,uart 关闭.


3. 如何确认 user/eng 版本

Java 层,check android.os.Build 类中的TYPE 值
native 层,property_get("ro.build.type", char* value, "eng"); 然后check value 值
Debug 时,adb shell getprop ro.build.type 返回值如果是 user 即 user 版本,eng 即 eng 版本
Log 确认, mobile log/Aplog_xxxxx/versions 中查看ro.build.type 属性


4. 如何编译 user/eng 版本

默认编译的是 eng 版本,如果需要编译 user 版本,请加入参数 -o=TARGET_BUILD_VARIANT=user 如:
./mk -o=TARGET_BUILD_VARIANT=user mt6577_phone new

default.prop和/system/build.prop

 

posted on 2019-07-26 11:02  Hello-World3  阅读(2345)  评论(0编辑  收藏  举报

导航