react-native icon indicating copy to clipboard operation
react-native copied to clipboard

The app is granting all android user permission automatically when installed with react-native run-android

Open lclrobert2020 opened this issue 4 years ago • 4 comments

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.

  1. use my code and put it in App.js
  2. add permission in AndroidManifest.xml <uses-permission android:name="android.permission.CAMERA" />
  3. run npx react-native run-android
  4. 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;

lclrobert2020 avatar Jun 03 '21 07:06 lclrobert2020

Add following permission to android>app>src>debug>AndroidManifest.xml

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

enestatli avatar Jun 03 '21 13:06 enestatli

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.

Theofilos-Chamalis avatar Jun 17 '21 10:06 Theofilos-Chamalis

I have the same exactly issue, but it happens both in debug (npm run android) and in release (npm run android -- --variant=release).

jzxchiang1 avatar Aug 03 '21 05:08 jzxchiang1

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.

github-actions[bot] avatar Feb 05 '24 05:02 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Feb 12 '24 05:02 github-actions[bot]