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.

Permission Error on Android

See original GitHub issue

Hello, I get this error on android and I can’t find a way to set these permissions, any idea?

Error: Could not get photos: need READ_EXTERNAL_STORAGE permission

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

5reactions
oteinonecommented, Jun 11, 2019

If anyone else stumbles here, here’s a short explanation:

Currently Android requires you to request these permissions separately on the go. Having uses-permission in manifest is not enough. The camera roll picker component has not updated to include this feature.

I managed to get the component working without any problems by asking the permission myself in the component using camera roll component. I added “rollPermissionExists” to the parent component’s state and only show the camera roll component if rollPermissionExists is true

Here’s a few code snippets to help anyone struggling with this (also remember to add rollPermissionExists and default value to your state).

Add PermissionsAndroid to your component

import { PermissionsAndroid } from 'react-native';

Call this method when you are about to show the camera roll component

// The 
async requestExternalStorageAccess() {
	try {
		const granted = await PermissionsAndroid.request(
			PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
		);
		if (granted === PermissionsAndroid.RESULTS.GRANTED) {
			this.setState({ rollPermissionExists: true })
		} else {
			this.setState({ rollPermissionExists: false })
		}
		} catch (err) {
		console.warn(err);
		}
}

Only show the picker if rollPermissionExists is true in render()

{ this.state.rollPermissionExists && <CameraRollPicker ... /> }
0reactions
rajnishcodercommented, Aug 23, 2018

agreed with @daose and if you are newly setup your project and cannot able to find android folder so run react-native eject read more to eject iOS and android app from react app.

and make sure you added CAMERA permission too like this:-

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

in your /android/app/src/main/AndroidManifest.xml file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change app permissions on your Android phone
On your phone, open the Settings app. · Tap Privacy And then Permission manager. · Tap a permission type. If you allowed or...
Read more >
Android permission error - manifest - Stack Overflow
this error occur due to security now in api 23 (mashmallow) version android improved there security they ask for permission if (android.os.
Read more >
Permission Denials - Android Developers
Via the Play console, Android vitals shows the percentage of daily permission sessions during which users denied permissions for your app.
Read more >
Android App Ticket Permission Error - Ubiquiti Community
In the android app, I can see the ticket, but trying to assign it at all gives me the error: "You don't have...
Read more >
Android 11 permission error - Google Groups
It might be caused by the sharing app, through the Content pick/shared block, not granting a "persistent" URI permission. I've also noticed that ......
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