1

I have an error in console after to install expo-camera.

  1. expo install expo-camera
  2. add permission in android manifest
  3. add module expo camera in maven

allprojects { repositories {

    // * Your other repositories here *

    // * Add a new maven block after other repositories / blocks *
    maven {
        // expo-camera bundles a custom com.google.android:cameraview
        url "$rootDir/../node_modules/expo-camera/android/maven"
    }
}

}

  1. start the protect

  2. click on the button to show camera ... error in log

    Error: Permissions module is null.

Permission:

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

update 1 : I test with this code example to check my permission https://reactnative.dev/docs/permissionsandroid my example function

 // state local
 const [hasPermission, setHasPermission] = useState(null);
 // function
 const requestCameraPermission = async () => {
        console.log('requestCameraPermission')
        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) {
                setHasPermission(true)
                console.log("You can use the camera");
            } else {
                console.log("Camera permission denied");
                setHasPermission(false)
            }
        } catch (err) {
            console.warn(err);
        }
    };

   // result of requestCameraPermission : You can use the camera
  //  Error  : Attempt to invoke interface method 'boolan expo.modules.interfaces.permission.Permission.hasGrantedPermissions(java.lang.string[]) on a null object reference

I make something wrong ? thanks for help

1 Answers1

0

If you did just these steps, you have to do more things to make it works on Android device.

Github page says:

Adjust the android/build.gradle to add a new maven block after all other repositories as described below:

allprojects {
    repositories {

        // * Your other repositories here *

        // * Add a new maven block after other repositories / blocks *
        maven {
            // expo-camera bundles a custom com.google.android:cameraview
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
    }
}

But before do that, you should:

For bare React Native projects, you must ensure that you have installed and configured the react-native-unimodules package before continuing.

Giovanni Esposito
  • 10,696
  • 1
  • 14
  • 30
  • I had install "react-native-unimodules": "^0.13.3", and for expo in maven , i add in last but same error I have in my project expo-barcode-scanner and it's work no problem. But expo-camera use the same permission , so i don't undertand. – rop lop fan Aug 06 '21 at 11:06
  • @roplopfan I tried locally and it worked... sorry to not be more helpful =( – Giovanni Esposito Aug 06 '21 at 11:59
  • maybe i need to clean my project ? i updated my post – rop lop fan Aug 06 '21 at 12:04
  • @roplopfan You could try `npm cache clean --force` – Giovanni Esposito Aug 06 '21 at 12:08
  • 1
    same problem... I use in my phone an android api 24. + firebase. Maybe it's the problem. I have this error if i would start my phone the component camera -> Attempt to invoke interface method 'boolan expo.modules.interfaces.permission.Permission.hasGrantedPermissions(java.lang.string[]) on a null object reference – rop lop fan Aug 06 '21 at 12:16
  • I can correct the prob. The prob concern only the react-native-unimodules. I update the last version and it's work. The version at the moment: "react-native-unimodules": "^0.14.6", thanks you for help @Giovanni Esposito – rop lop fan Aug 06 '21 at 13:39
  • @roplopfan I'm very happy you solved. Have a nice coding =) – Giovanni Esposito Aug 06 '21 at 13:40