Can't use permissions API in SDK 29

#1

After upgrading to SDK 29, I am getting an error when I try to request location permissions in my detached app:

Error: No visible activity. Must request location when visible.

I have replicated this in a fresh expo app by:
exp init
exp detach

Note: I got errors in android studio until I added expokit as a dependency in package.json

Once I have the default app up and running, I add componentDidMount in the default App.js and request location permission:

Permissions.askAsync(Permissions.LOCATION)

This gives the error:
[11:55:23] [Unhandled promise rejection: Error: No visible activity. Must request location when visible.]

  • node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:121:42 in createErrorFromErrorData
  • node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:78:57 in
  • … 5 more stack frames from framework internals

I am using exp version 55.0.5

Any advice or help with this would be appreciated.

1 Like
#2

I Have the same Issue, on detached App

#3

A fix was recently landed, which should fix this Permissions issue.
cc: @tsapeta @sjchmiela

1 Like
#4

Hi all, I confirmed this issue exists, it happens due to a bug in DetachedModuleRegistryAdapter, which doesn’t add modules from ReactAdapterPackage to the module registry. I’ll fix this issue upstream and post here a quick workaround for detached applications in a bit.

1 Like
#5

Hi all!

A quick workaround would be to:

  1. create your own subclass of ModuleRegistryAdapter.
  2. create your own subclass of UIManagerModuleWrapper.
  3. point MainActivity to use your ModuleRegistryAdapter subclass.

Classes for 1. and 2. can be found here: https://gist.github.com/sjchmiela/cbe0738171be44feb04f6342a5c352b8

To point to your subclass, override this method in MainActivity:

  @Override
  public ExpoModuleRegistryAdapter getScopedModuleRegistryAdapterForPackages(List<Package> packages) {
    return new MyModuleRegistryAdapter(new ReactModuleRegistryProvider(packages));
  }

Sorry for the inconvenience, we’re working on a fix. :slight_smile:

2 Likes
Android Detached SDK 29 Permissions and Gradle Errors
#6

Hi all,
Thank you very much for getting back to me so quickly about this, I do appreciate it.

The workaround did the trick and everything is now working again.

I’ll keep an eye out for the upstream fix as well.

Thanks again for your help!

1 Like
#7

@sjchmiela, this code works on develop mode, when i build a release APK, the Notifications requests stop working again.

    buildTypes {
        debug {
            debuggable true
            ext.enableCrashlytics = false
            signingConfig signingConfigs.configs
        }
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            zipAlignEnabled true
            signingConfig signingConfigs.configs
        }
    }
Can't build android project after detaching from Expo SDK 28.0.0
Ask for multiple permissions
#8

It Works by Removing ‘minifyEnabled’ and ‘proguardFiles’

        release {
            zipAlignEnabled true
            signingConfig signingConfigs.configs
        }
#9

Could you please clarify what do you mean by Notifications requests stop working? :slightly_smiling_face:

1 Like
#10

@sjchmiela
When use Permission.asksync(…), do nothing!

1 Like
#11

I’m also with the same issue. I created an “issue” on github and linked to this post. https://github.com/expo/expo/issues/2087

#12

Hi all, thanks for your patience?

Could you please follow the instructions I’ve put in https://github.com/expo/expo/issues/2087#issuecomment-414996822 and see if it helps to resolve the issue?

1 Like
closed #13

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.