Reputation: 630
For security purposes, I want to store the IMEI number of app users but I am getting the following error
2020-02-14 13:29:36.620 14794-14794/com.udaan.android.creditoperations E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.udaan.android.creditoperations, PID: 14794
java.lang.SecurityException: getImeiForSlot: The user 10643 does not meet the requirements to access device identifiers.
at android.os.Parcel.createException(Parcel.java:2071)
at android.os.Parcel.readException(Parcel.java:2039)
at android.os.Parcel.readException(Parcel.java:1987)
at com.android.internal.telephony.ITelephony$Stub$Proxy.getImeiForSlot(ITelephony.java:10471)
at android.telephony.TelephonyManager.getImei(TelephonyManager.java:1754)
at android.telephony.TelephonyManager.getImei(TelephonyManager.java:1715)
Is there any way to access IMEI number including latest android devices?
Upvotes: 3
Views: 15829
Reputation: 51
From Android 10, there is no way to get it. Find an alternative unique identifier from document which shared by Abhishek.
Starting in Android 10, apps must have the READ_PRIVILEGED_PHONE_STATE privileged permission in order to access the device's non-resettable identifiers, which include both IMEI and serial number.
Caution: Third-party apps installed from the Google Play Store cannot declare privileged permissions.
More details;
https://developer.android.com/about/versions/10/privacy/changes
Upvotes: 2
Reputation: 3584
Starting from Android 10, Third-party apps installed from the Google Play Store cannot get IMEI number. That's why you are getting this Security Exception.
I would suggest you use any other unique id for your purpose. For best practices of unique identifiers recommended by Google, you can check out the below link
https://developer.android.com/training/articles/user-data-ids
Upvotes: 3
Reputation: 81
Have you tried to add permission to AndroidManifest file?
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Upvotes: 0