question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

getSerialNumberSync api error?

See original GitHub issue

Bug report

when android SDK < 26, getSerialNumberSync() always return “unknown”?

 public String getSerialNumberSync() {
     try {
       if (Build.VERSION.SDK_INT >= 26) {
         if (getReactApplicationContext().checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
           return Build.getSerial();
         }
       }
     } catch (Exception e) {
       // This is almost always a PermissionException. We will log it but return unknown
       System.err.println("getSerialNumber failed, it probably should not be used: " + e.getMessage());
     }
     return "unknown";
   }

Environment info

react-native info output:

# "react-native": "0.62.2",
# "react-native-device-info": "^5.5.7",

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
stewartmcgowncommented, Nov 1, 2020

In case someone stumbles across this from Google and is in the same very specific sitation:

Add this topatches/react-native-device-info+7.0.2.patch:

--- a/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
+++ b/node_modules/react-native-device-info/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
@@ -655,6 +655,8 @@
         if (getReactApplicationContext().checkCallingOrSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED) {
           return Build.getSerial();
         }
+      } else {
+        return Build.SERIAL;
       }
     } catch (Exception e) {
       // This is almost always a PermissionException. We will log it but return unknown

Grab these two packages:

"patch-package": "^6.2.2",
"postinstall-postinstall": "^2.1.0",

Then add a postinstall script:

"scripts": {
   ...,
  "postinstall": "patch-package"
}
1reaction
M45tercommented, Aug 12, 2020

this is better?

if (Build.VERSION.SDK_INT >= 26) {
...
} else {
     return Build.SERIAL;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

API Error Codes - React chat - GetStream.io
Below you can find the complete list of errors that are returned by the API together with the description, API code, and corresponding...
Read more >
Example to Get Device Information in React Native
You will see how to access the device information using different ways (Sync, Async, Constant, Hook) in React Native using React Native Device...
Read more >
INNOVATIVE TECHNOLOGY LTD SSP. Communications ...
Command Reset Host Protocol Version Get Serial Number Sync Disable Enable Get ... SOFTWARE ERROR 0xF6 Reported for errors in the execution of...
Read more >
2021年07月_weixin_39778214的博客_CSDN博客
Error message when i am wanting to create a new user. 2021-01-12 ... getSerialNumberSync api error? 2021-01-12 ... getSerialNumberSync api error? 2021-01-12 ...
Read more >
Fix Steam API Error | Simple Guide | Updated - YouTube
Trying to play Steam games, but can't? Getting a Steam API error ? This video shows you some simple steps to get back...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found