eng, user, userdebug 的不同

本文详细介绍了Android源码编译时的三种不同选项:eng、user 和 userdebug 的区别。这些选项通过 Android.mk 文件中的 LOCAL_MODULE_TAGS 配置来决定,并且会直接影响编译过程中的模块选择与配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The difference between Android source code compiler options eng, user, userdebug




The difference between Android source code compiler options eng, user, userdebug


1, A brief description of each option


eng: Debug version

User:release version

UserDebug version: debug version

2, Details

Android source code compiler options eng, user, userdebug is a Android.mk file in the LOCAL_MODULE_TAGS configuration to decide. Following its general form:

LOCAL_MODULE_TAGS := user eng optional test
The details are as follows: 

1, user: Only when the user version of the module was compiled.,

2, eng: Only when the eng version of the module was compiled.,

3, test: Only when the tests version of the module was compiled.,

4, optional: In all versions are compiled into the module.

One of the value can be set to 1 or more, respectively corresponding compiler options with one or more.

eng, user, Userdebug the difference is as follows:

1, When make eng, which is equivalent to make. When the BuildType is eng, then the compiler in include:

·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 taggedAPKs

·Sets ro.secure=1

·Sets ro.debuggable=0

·Sets ro.kernel.android.checkjni=1

·adbd is enabled by default

2, When make user, then BuildType is user, then the compiler in include:

·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 forAPK modules)

·Sets ro.secure=1

·Sets ro.debuggable=0

·adbd is disabled by default

3, When make userdebug, then BuildType is userdebug, then the compiler in include:

thesame as user, except:

·Intended for limited debugging

·Installs modules tagged with debug

·Sets ro.debuggable=1

·adbd is enabled by default


3, Distribute :


eng

This is the default flavor. A plain "make " is the same as "make eng ". droid is an alias foreng .

· 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.

· ro.secure=0

· ro.debuggable=1

· ro.kernel.android.checkjni=1

· adb is enabled by default.

user

"make user "

This is the flavor intended to be the final release bits.

· Installs modules tagged with user .

· Installs non-APK modules that have no tags specified.

· Installs APKs according to the product definition files; tags are ignored for APK modules.

· ro.secure=1

· ro.debuggable=0

· adb is disabled by default.

userdebug

"make userdebug "

The same as user , except:

· Also installs modules tagged with debug .

· ro.debuggable=1

· adb is enabled by default.


<think>嗯,用户想知道如何在Android设备上检测当前运行的版本是否为userdebug。我需要根据他们提供的引用资料来整理答案。首先,引用1提到通过TARGET_BUILD_VARIANT来判断编译版本,如果是userdebugeng的话,ALLOW_ADBD_NO_AUTH为1。这可能是在编译时的属性,但用户可能想知道在运行时如何检测。然后引用3提到了adb shell命令来查看版本,比如通过getprop或者检查ro.build.type属性。 用户的问题分两个部分:检测当前运行的build类型是否为userdebug,以及如何在代码中进行判断。根据引用3,使用adb shell getprop ro.build.type可以返回useruserdebugeng。这应该是一个直接的方法。另外,在代码中,可以通过Build.TYPE来获取这个属性,比如Build.TYPE.equals("userdebug")。需要确认这个字段是否可靠,但根据常见的Android API,Build类确实包含这些信息。 另外,引用1提到的TARGET_BUILD_VARIANT可能是在编译时的变量,而用户可能需要的是运行时检测。所以答案应该集中在运行时的方法,比如使用系统属性或者Build类的字段。另外,用户可能没有root权限,所以方法应该不需要root。adb方法适合通过命令行检查,而代码中的方法适合在应用内部判断。 还要注意用户可能是在开发过程中需要这个判断,比如根据不同的版本启用不同的功能或日志。需要确保提供的方法准确,并且考虑到不同的设备可能有不同的设置,比如自定义ROM可能修改这些属性,但一般情况下,ro.build.type是标准的。</think>在Android中检测当前设备是否为userdebug版本,可以通过以下方法实现: ### 方法一:通过系统属性获取 1. 使用`adb shell`执行命令: ```bash adb shell getprop ro.build.type ``` 若输出结果为$userdebug$,则表明当前为调试版本。其他可能结果包括$user$(正式版)和$eng$(工程机)[^3]。 2. 在Java代码中判断: ```java if (Build.TYPE.equals("userdebug")) { // 当前为userdebug版本 } ``` 通过`Build.TYPE`字段直接获取编译类型[^2]。 ### 方法二:检查adb root权限 在userdebug版本中可通过以下命令验证: ```bash adb root adb remount ``` 若成功获取root权限且可重新挂载系统分区,则表明是调试版本(注意:需要设备已开启USB调试授权)[^1]。 ### 方法三:查看系统文件 检查`/system/build.prop`文件中的属性: ```bash adb shell grep "ro.build.type" /system/build.prop ``` 该文件包含完整的构建属性信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值