3

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)
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
GladiatorAsif
  • 76
  • 1
  • 5
  • 1
    I can think of two cases where the behavior you're describing can happen: [1] if signing keys don't match - note that app can be signed with multiple keys, and the calculation takes into account all of them; also, if you're opted into Google Play app signing for one of the apps - the eventual APK's signing key will be Play's; [2] if you running the apps on two different [users](https://source.android.com/devices/tech/admin/multi-user#user_types). – Alex Lipov Oct 09 '19 at 11:18

3 Answers3

5

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

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
  • 2
    I am using same signing key for both apps. If it is using combination of app signing key as well as user, can you define what "user" is referring here? – GladiatorAsif Jul 18 '18 at 10:50
  • @NileshRathore Please help me on one doubt. How to get the device ID which is become same for all the devices and can not be revert when device reboot or data wiped out..Can you please suggest the way to get the device id which is become same for all app.. Thanks – Ravindra Kushwaha Oct 21 '20 at 10:12
0

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

Udit
  • 1,037
  • 6
  • 11
  • 2
    But i am using same signing keys for both apps so ideally it should return same Android Id. Can you define what "user" is referring here? – GladiatorAsif Jul 18 '18 at 10:46
0

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.

geosmart
  • 518
  • 4
  • 15