简体   繁体   中英

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. This problem is occurring only in Android Oreo OS. Can anyone help me why there are 2 different Android IDS generated?

The method i am using for 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

Please Read about Android 8.0 Behavior Changes

  • 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. To preserve values across uninstalls after OTA, developers can associate the old and new values by using Key/Value Backup.

  • 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. The value of ANDROID_ID is unique for each combination of app-signing key, user, and device. 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).

That is the expected behaviour on Oreo and above devices. Device Id is now unique for every app for each user.

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. The value of ANDROID_ID is unique for each combination of app-signing key, user, and device. 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).

Link: 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". These unique IDs are stored in

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

When android_id value init, the first time set the value? Which case does the android_id value change? 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.

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

Keeping all in view it doesn't seem a good idea to build a device_id with android_id.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM