zoontek / react-native-permissions

An unified permissions API for React Native on iOS, Android and Windows.
MIT License
4.11k stars 837 forks source link

Crash on Android: Unable to resume activity java.lang.reflect.InvocationTargetException #871

Closed ampopdev closed 7 months ago

ampopdev commented 7 months ago

Before submitting a new issue

Bug summary

On some devices like Oppo Realme 7i with Android 10 it's crashing when calling request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION):

Fatal Exception: java.lang.RuntimeException: Unable to resume activity {com.myapp/com.myapp.MainActivity}: java.lang.reflect.InvocationTargetException at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4486) at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4524) at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:181) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:102) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2207) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:238) at android.app.ActivityThread.main(ActivityThread.java:7834) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:512) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:986)

Library version

4.1.5

Environment info

System:
    OS: macOS 14.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 55.44 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.10.0 - ~/.nvm/versions/node/v18.10.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.10.0/bin/yarn
    npm: 8.19.2 - ~/.nvm/versions/node/v18.10.0/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.12.1 - /opt/homebrew/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.4, iOS 17.4, macOS 14.4, tvOS 17.4, visionOS 1.1, watchOS 10.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.2 AI-222.4459.24.2221.9971841
    Xcode: 15.3/15E204a - /usr/bin/xcodebuild
  Languages:
    Java: 17.0.6 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0 
    react-native: 0.72.11 => 0.72.11 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. Just run request location permission
  2. Answer permission
  3. Crash

Reproducible sample code

await request(PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION)
zoontek commented 7 months ago

ACCESS_FINE_LOCATION should be required with ACCESS_COARSE_LOCATION (using requestMultiple): https://developer.android.com/develop/sensors-and-location/location/permissions#approximate-request