react-native
react-native copied to clipboard
The app is granting all android user permission automatically when installed with react-native run-android
Please provide all the information requested. Issues that do not follow this format are likely to stall.
Description
The app is granting all android user permission automatically when installed with react-native run-android. Even for the permission like CAMERA
React Native version:
System: OS: macOS 11.2.1 CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz Memory: 73.53 MB / 8.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.10.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.5.3 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 23, 28, 29, 30 Build Tools: 23.0.1, 28.0.3, 29.0.2, 30.0.2, 30.0.3 System Images: android-28 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.7042882 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_282 - /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.1 => 0.64.1 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- use my code and put it in App.js
- add permission in AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA" /> - run npx react-native run-android
- you will discovered that pop up is not showing when pressing the btn because ALL permission is granted once installed
Expected Results
Permission like CAMERA SHOULD NOT granted automatically. This only happend when installing with npx react-native run-android. If you pack a debug apk and install on phone, the permission is not granted automatically. It is not convenient for devs to test the app
Snack, code example, screenshot, or link to a repository:
import React from "react";
import { Button, PermissionsAndroid, SafeAreaView, StatusBar, StyleSheet, Text, View } from "react-native";
const requestCameraPermission = async () => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.CAMERA,
{
title: "Cool Photo App Camera Permission",
message:
"Cool Photo App needs access to your camera " +
"so you can take awesome pictures.",
buttonNeutral: "Ask Me Later",
buttonNegative: "Cancel",
buttonPositive: "OK"
}
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log("You can use the camera");
} else {
console.log("Camera permission denied");
}
} catch (err) {
console.warn(err);
}
};
const App = () => (
<View style={styles.container}>
<Text style={styles.item}>Try permissions</Text>
<Button title="request permissions" onPress={requestCameraPermission} />
</View>
);
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: "center",
paddingTop: StatusBar.currentHeight,
backgroundColor: "#ecf0f1",
padding: 8
},
item: {
margin: 24,
fontSize: 18,
fontWeight: "bold",
textAlign: "center"
}
});
export default App;
Add following permission to android>app>src>debug>AndroidManifest.xml
<uses-permission android:name="android.permission.CAMERA" />
I can confirm that I have the same issue as @lclrobert2020 .
The permissions that I have tested are the following:
PERMISSIONS.ANDROID.CAMERA,
PERMISSIONS.ANDROID.RECORD_AUDIO,
PERMISSIONS.ANDROID.ACCESS_COARSE_LOCATION,
PERMISSIONS.ANDROID.ACCESS_FINE_LOCATION,
PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE,
PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE,
which I ve also added to the AndroidManifest.xml and performed a ./gradlew clean command after doing so and prior to running the yarn android command. This happens only while in debug mode and not when producing a release build .apk artifact.
I have the same exactly issue, but it happens both in debug (npm run android) and in release (npm run android -- --variant=release).
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.