Android編譯選項eng、user、userdebug的區別


1. eng:debug版本;2. user:release版本;3. userdebug版本:部分debug版本

Android.mk文件中有配置項:LOCAL_MODULE_TAGS,一般配置值為:user/eng/optional/test四個值。

那么LOCAL_MODULE_TAGS設置為不同值有何作用呢?下面是對應不同值編譯的結果:

    1、user:只有在user版本時該模塊才被編譯進去(用戶版本);

    2、eng:只有在eng版本時該模塊才被編譯進去(工程版本);

    3、test:只有在tests版本時該模塊才被編譯進去;

    4、optional:在所有版本中都編譯該模塊進去。

其中的值可設置為1個或多個,分別對應編譯選項的同一個或多個。那么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

各版本之間的差異:

(1) Debug/LOG 方面,原則上user 版本只能抓到有限的資訊,eng 可以抓到更多的資訊,Debug 能力更強,推崇使用eng 版本開發測試

*       因user/eng 版本設置ro.secure不同,導致user 版本adb 只擁有shell 權限,而eng 版本具有root 權限

*       MTK System LOG 在ICS 以后,在user 版本默認關閉全部LOG, 在eng 版本中默認打開,以便抓到完整的資訊

*       在eng 版本上,LOG 量 >= user 版本的log 量,一些地方會直接check eng/user 版本來確認是否打印LOG

*       user 版本默認關閉uart, eng 版本默認開啟uart

*       在eng 版本上,開啟ANR 的predump, 會抓取ftrace,可以得到更多ANR的資訊

*       在eng 版本上,可用rtt 抓取backtrace,可開啟kdb 進行kernel debug, 可用ftrace 抓取cpu 執行場景

*       MTK aee 在ENG 版本抓取更多的異常資訊,比如native exception 會抓取core dump 信息

(2) 性能方面,原則上進行性能測試請使用user 版本測試

*       user 版本為提高第一次開機速度,使用了DVM 的預優化,將dex 文件分解成可直接load 運行的odex 文件,ENG 版本不會開啟這項優化

*       更少的LOG 打印,uart 的關閉,原則上user 版本的性能要優於eng 版本

(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

eng工程版本:adb默認是打開的,且設置向導是可選的。

user用戶版本:adb默認是關閉的,dex打開(提高速度)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM