Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build.GetSerial() returns unknown on API 29

I cant get serial on android 10 device.

I know about everything(permission, runtime permissions, I get serial only after the permission is granted) from here android Build.GetSerial() throwing exception

My code works on all android versions, except 10

Do you have any ideas?

like image 734
Dmitry Zinoviev Avatar asked Dec 13 '19 16:12

Dmitry Zinoviev


People also ask

What is build fingerprint?

android.os.Build.FINGERPRINT: A string that uniquely identifies this build. It SHOULD be reasonably human-readable. It MUST follow this template: $(BRAND)/$(PRODUCT)/$(DEVICE)/$(BOARD):$(VERSION.RELEASE)/$(ID)/$(VERSION.INCREMENTAL):$(TYPE)/$(TAGS)

What is build in Android?

The Android build system compiles app resources and source code, and packages them into APKs or Android App Bundles that you can test, deploy, sign, and distribute.

How do I find the serial number of my Android 10?

In the device's system settings: Settings->System->About Tablet->Model->Serial number.

What is device build?

A build is a software version for a specific device - hence a build number is of course not unique. All devices with the same software version will have the same build id.


1 Answers

If you follow the official documentation here: https://developer.android.com/reference/android/os/Build.html#getSerial(), more info on Android 10 changes here

You will notice that starting from Android 10 this method is returning Build.UNKNOWN. You can't use it to uniquely identify a single device anymore

You need to switch to the "less" persistent version called Settings.Secure.ANDROID_ID

The only ways to bypass this restriction are:

  1. Create a system app to be able to get the READ_PRIVILEGED_PHONE_STATE system permission (a normal app can't get this).
  2. Be registered as a carrier (which requires you to have built the Android ROM)
  3. Have a custom "work profile" to set your own policies in the device.

As you can imagine, all those options are not meant to be used by standard android app developers

like image 176
MatPag Avatar answered Sep 28 '22 17:09

MatPag