android 11 android.permission.READ_PHONE_NUMBERS
See original GitHub issueDescription
I’ve been trying to solve this problem for 2 days this problem only happens on android 11
when I changed targetSDKversion from 29 to 30 my app works good for only first oppening when I give permissions my app crash and I’m getting this error
LOGCAT ERRORS:
11-12 11:42:55.338 899 1105 E unknown:ReactNative: java.lang.SecurityException: getLine1NumberForDisplay: Neither user 10205 nor current process has android.permission.READ_PHONE_STATE, android.permission.READ_SMS, or android.permission.READ_PHONE_NUMBERS 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at android.os.Parcel.createExceptionOrNull(Parcel.java:2373) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at android.os.Parcel.createException(Parcel.java:2357) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at android.os.Parcel.readException(Parcel.java:2340) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at android.os.Parcel.readException(Parcel.java:2282) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.android.internal.telephony.ITelephony$Stub$Proxy.getLine1NumberForDisplay(ITelephony.java:10831) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at android.telephony.TelephonyManager.getLine1Number(TelephonyManager.java:4479) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at android.telephony.TelephonyManager.getLine1Number(TelephonyManager.java:4447) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.learnium.RNDeviceInfo.RNDeviceModule.generateConstants(RNDeviceModule.java:547) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.learnium.RNDeviceInfo.RNDeviceModule.<init>(RNDeviceModule.java:84) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.learnium.RNDeviceInfo.RNDeviceInfo.createNativeModules(RNDeviceInfo.java:28) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.facebook.react.ReactPackageHelper.getNativeModuleIterator(ReactPackageHelper.java:42) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:41) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1212) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1182) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1120) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:123) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:943) 11-12 11:42:55.338 899 1105 E unknown:ReactNative: at java.lang.Thread.run(Thread.java:923)
Manifest File:
Version
0.59.9
Output of react-native info
React Native Environment Info:
System:
OS: Windows 10
CPU: (12) x64 Intel® Core™ i5-10500 CPU @ 3.10GHz
Memory: 2.74 GB / 15.83 GB
Binaries:
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.10 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 4.1.0.0 AI-201.8743.12.41.7199119
Steps to reproduce
upgrade targetSDKversion from 29 to 30 add READ_PHONE_NUMBERS permissions for android 11
Snack, code example, screenshot, or link to a repository
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
Android 11 introduced changes on the READ_PHONE_STATE permissions: https://developer.android.com/about/versions/11/privacy/permissions
The crash seems to be unrelated to react-native. Are you calling
.requestPermission
correctly? Could you provide a reproducer using an empty template?I have resolved my issue with the below changes
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
After<uses-permission android:name="android.permission.READ_PHONE_STATE" android:maxSdkVersion="29" /> <uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
buildscript { ext { googlePlayServicesVersion = "16.1.0" firebaseVersion = "17.3.4" buildToolsVersion = "30.0.2" minSdkVersion = 21 compileSdkVersion = 30 targetSdkVersion = 30 supportLibVersion = "28.0.0" }...
await PermissionsAndroid.requestMultiple([ PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE, PermissionsAndroid.PERMISSIONS.READ_CALL_LOG, PermissionsAndroid.PERMISSIONS.READ_CONTACTS]);