简体   繁体   English

为同一设备获取不同的 ID。 为什么?

[英]Getting different IDs for same device. Why?

I am getting different Android IDs for same device for 2 apps in spite of they are being signed with same keystore.尽管它们使用相同的密钥库进行签名,但我为 2 个应用程序在同一设备上获得了不同的 Android ID。 This problem is occurring only in Android Oreo OS.此问题仅在 Android Oreo OS 中发生。 Can anyone help me why there are 2 different Android IDS generated?谁能帮助我为什么会生成 2 个不同的 Android IDS?

The method i am using for Android Id -我用于 Android Id 的方法 -

int deviceId = Settings.Secure.getString(pContext.getContentResolver(), Settings.Secure.ANDROID_ID)

Its behaving as intended.它的行为符合预期。 in Android 8.0, the value of ANDROID_ID is now scoped per app means ANDROID_ID is now unique for every app在 Android 8.0 中, ANDROID_ID的值现在是针对每个应用的,这意味着ANDROID_ID现在对于每个应用都是唯一的

Please Read about Android 8.0 Behavior Changes请阅读Android 8.0 行为变化

  • For apps that were installed prior to an OTA to a version of Android 8.0 (API level 26) (API level 26), the value of ANDROID_ID remains the same unless uninstalled and then reinstalled after the OTA.对于在 OTA 之前安装到 Android 8.0(API 级别 26)(API 级别 26)版本的应用程序,ANDROID_ID 的值保持不变,除非在 OTA 之后卸载然后重新安装。 To preserve values across uninstalls after OTA, developers can associate the old and new values by using Key/Value Backup.为了在 OTA 后跨卸载保留值,开发人员可以使用键/值备份来关联旧值和新值。

  • For apps installed on a device running Android 8.0, the value of ANDROID_ID is now scoped per app signing key, as well as per user.对于安装在运行 Android 8.0 的设备上的应用,ANDROID_ID 的值现在适用于每个应用签名密钥以及每个用户。 The value of ANDROID_ID is unique for each combination of app-signing key, user, and device. ANDROID_ID 的值对于应用签名密钥、用户和设备的每个组合都是唯一的。 As a result, apps with different signing keys running on the same device no longer see the same Android ID (even for the same user).因此,在同一设备上运行的具有不同签名密钥的应用不再看到相同的 Android ID(即使是同一用户)。

That is the expected behaviour on Oreo and above devices.这是 Oreo 及以上设备的预期行为。 Device Id is now unique for every app for each user.现在对于每个用户的每个应用程序,设备 ID 都是唯一的。

Android official documentation:安卓官方文档:

For apps installed on a device running Android 8.0, the value of ANDROID_ID is now scoped per app signing key, as well as per user.对于安装在运行 Android 8.0 的设备上的应用,ANDROID_ID 的值现在适用于每个应用签名密钥以及每个用户。 The value of ANDROID_ID is unique for each combination of app-signing key, user, and device. ANDROID_ID 的值对于应用签名密钥、用户和设备的每个组合都是唯一的。 As a result, apps with different signing keys running on the same device no longer see the same Android ID (even for the same user).因此,在同一设备上运行的具有不同签名密钥的应用不再看到相同的 Android ID(即使是同一用户)。

Link: https://developer.android.com/about/versions/oreo/android-8.0-changes链接: https : //developer.android.com/about/versions/oreo/android-8.0-changes

Since Android 8, android_id is "unique to each combination of app-signing key, user, and device" so as to deny "developers the ability to track users across multiple applications".从 Android 8 开始, android_id “对于应用签名密钥、用户和设备的每个组合都是唯一的”,从而拒绝“开发人员能够跨多个应用程序跟踪用户”。 These unique IDs are stored in这些唯一的 ID 存储在

/data/system/users//settings_ssaid.xml. /data/system/users//settings_ssaid.xml。

When android_id value init, the first time set the value?当android_id值init时,第一次设置值? Which case does the android_id value change? android_id 值在哪种情况下会发生变化? As evident, android_id "is randomly generated when the user first sets up the device and should remain constant for the lifetime of the user's device" unless a factory reset is performed which clears all settings.很明显,android_id“是在用户第一次设置设备时随机生成的,并且应该在用户设备的整个生命周期内保持不变”,除非执行了清除所有设置的出厂重置。

On Android 8+ the app specific android_id "value may change if a factory reset is performed on the device or if an APK signing key changes".在 Android 8+ 上,特定于应用程序的 android_id “如果在设备上执行出厂重置或 APK 签名密钥更改,则值可能会更改”。

Keeping all in view it doesn't seem a good idea to build a device_id with android_id.考虑到所有情况,使用 android_id 构建 device_id 似乎不是一个好主意。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在mobilefirst控制台中为设备列出设备ID和设备型号时,未为同一设备生成用户ID。 为什么? - While Device id and Device model is getting listed for a device in mobilefirst console, User id not getting generated for the same device. Why? GoogleCloudMessaging#register在同一个应用/设备中返回不同的ID? - GoogleCloudMessaging#register returns different IDs in the same app / device? 点击另一个启用NFC的设备后,无法进入onNewIntent。(android) - not getting to onNewIntent after tapping to another NFC enabled device.(android) 包名称不同的Android应用程序无法安装在同一设备上。 - Android applications with differnt package names are not able to install in same device. 奇怪的问题-Android应用在某些设备上崩溃。 为什么? - weird issue - android app crashes at some of the device. why is it? ?android:attr / actionBarSize不能仅在一台设备上运行。 为什么? - ?android:attr/actionBarSize not working in only one device. Why? 获取包名称与同一应用程序的不同应用程序ID冲突 - Getting package name conflict with different application ids of the same app 我正在做一个项目,不断给我以前配对过的设备的RSSI。 我没有得到连续的结果 - Im doing a project which continuously gives me RSSI of a previously paired device. Im not getting continuous results 无法在真实设备上运行appium脚本。 收到错误的应用错误 - Not able to run appium script on real device. getting a bad app error 在使用不同版本的Android设备扫描时,为同一个BLE设备获取不同的byte [] scanRecord数据 - Getting different byte[] scanRecord data for same BLE device while scanning with different versions of android device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM