Access denied for property “vendor.camera.aux.packagelist”

前端 未结 6 2118
暗喜
暗喜 2021-01-05 05:03

The application runs but when i try to use the camera only a disturbed grey screen appears and the logs tab gives me two errors:

E/libc: Access denied findin         


        
相关标签:
6条回答
  • 2021-01-05 05:18

    If you are using a firebase plugin in your project, remove it. I was using the firebase crashlytics that camera prevents opening.

    0 讨论(0)
  • 2021-01-05 05:23

    I had this in my android manifest that prevented the app from using the camera.

    android:hardwareAccelerated="false"
    

    Removing it helped me.

    0 讨论(0)
  • 2021-01-05 05:24

    First, check your Android version. If it is running on Android 6.0 and higher (API level 23+), then you need to :

    Declare a permission in the app manifest. Make sure to insert the permission above the application tag.

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-feature android:name="android.hardware.camera" />
    
    <application ...>
        ...
    </application>
    

    Then, request that the user approve each permission at runtime

    if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != 
    PackageManager.PERMISSION_GRANTED) { 
    ActivityCompat.requestPermissions(this, new String[] {Manifest.permission.CAMERA}, 
    50); }
    
    0 讨论(0)
  • 2021-01-05 05:28

    I am also seeing same error in my console when I am trying to open camera. However, it does not cause any other side effects.

    I think it's best to ignore this error unless it stops app from running. or limits any functionality.

    Found a post here that claims to resolve the issue by adding

    <application>
    <uses-library android:name="org.apache.http.legacy" android:required="false"/>
    </application>
    

    However, this did not work in my case. Testing on Mi Note 7

    0 讨论(0)
  • 2021-01-05 05:29

    Firstly, to check if it is a permission problem, go to the application manager of your phone, find your programme's name, and check the permission list. See if it is allowed to use the camera.

    Secondly, open the XML of the layout where your "SurfaceView" resides, check if the "SurfaceView" node has the property "android:background". You must remove it if it is there. No idea why this is never mentioned.

    <SurfaceView
            android:layout_width="0dp"
            android:layout_height="300dp" android:id="@+id/cameraPreview"
            app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toEndOf="parent" android:background="#3F51B5"/>
    

    Pay attention to the "android:background" in the above snippet. Remove it if you see it.

    Thirdly, make sure you start the camera in the "surfaceCreated" event handler rather than anywhere else. You can't directly start the camera in "onViewCreated"!

    Sample code just in case:

    public void onViewCreated(@NonNull final View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    
        final CameraSource cameraSource = new CameraSource.Builder(getContext(), barcodeDetector)
                .setRequestedPreviewSize(640, 480)
                .setRequestedFps(10)
                .setAutoFocusEnabled(true).build();
    
        ((SurfaceView) view.findViewById(R.id.cameraPreview)).getHolder().addCallback(new SurfaceHolder.Callback() {
            @Override
            public void surfaceCreated(SurfaceHolder holder) {
                if(ContextCompat.checkSelfPermission(getContext(), Manifest.permission.CAMERA)
                        != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(getActivity(), new String[]{Manifest.permission.CAMERA}, 1);
                }
    
                try {
                    cameraSource.start(holder);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
    
            @Override
            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
    
            @Override
            public void surfaceDestroyed(SurfaceHolder holder) {
                cameraSource.stop();
            }
        });
    }
    
    0 讨论(0)
  • 2021-01-05 05:31

    I too faced same error while implementing video capture option, this in my case due to missing Storage and Camera permissions.

    Resolved using below code

      if ((checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) || (checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED))  {
                    Log.d(TAG, "No camera and storage permission");
                    requestPermissions(new String[]{Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE}, MY_PERMISSIONS_REQUEST_CODE);
                }
    
    0 讨论(0)
提交回复
热议问题