Access denied for property "vendor.camera.aux.packagelist"
Asked Answered
R

9

17

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 finding property "vendor.camera.aux.packagelist"
        Access denied finding property "vendor.camera.aux.packagelist2"

AndroidManifest.xml

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

build.gradle (Module:app)

apply plugin: 'com.android.application'
android {
    compileSdkVersion 28
    defaultConfig {
        minSdkVersion 22
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:recyclerview-v7:28.0.0'
}

build.gradle(Project:camera)

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.0'
    }
}
allprojects {
    repositories {
        google()
        jcenter()

    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

Remote answered 5/5, 2019 at 8:46 Comment(2)
Did you get any solution to this issue?Donato
Not yet...I tried to reinstall Android studio and all the packages but nothing changed @DonatoRemote
P
9

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); }
Perihelion answered 28/6, 2019 at 12:14 Comment(3)
Where in the project do you put that if statement, please?Stately
@KarolinaHagegård Conventionally we do that in Splash Activity, when requesting permissions in Native Android developmentPerihelion
Ok... Well, I'm using Flutter, and it seems to do that automatically. At least on my phone, it doesn't ask for permission until I need it.Stately
Q
3

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

android:hardwareAccelerated="false"

Removing it helped me.

Quintonquintuple answered 6/8, 2019 at 18:0 Comment(0)
G
1

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();
        }
    });
}
Garek answered 23/6, 2020 at 16:14 Comment(0)
A
1

Reason: FileNotFoundException open failed: XXXXXXX EPERM (Operation not permitted)

Adding all the permissions still reports an error, mainly because the permissions requirements of the Android system are very strict.

It is recommended to change to:

ContextWrapper cw = new ContextWrapper(getApplicationContext());
File directory = cw.getExternalFilesDir(Environment.DIRECTORY_MUSIC);
File file = new File(directory, "something" + ".MP3");

public static String DIRECTORY_MUSIC = "Music";
public static String DIRECTORY_ALARMS = "Alarms";
public static String DIRECTORY_NOTIFICATIONS = "Notifications";
public static String DIRECTORY_PICTURES = "Pictures";
public static String DIRECTORY_MOVIES = "Movies";
public static String DIRECTORY_DOWNLOADS = "Download";
public static String DIRECTORY_DCIM = "DCIM";
public static String DIRECTORY_DOCUMENTS = "Documents";
Anchoveta answered 19/5, 2021 at 4:36 Comment(0)
S
0

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

Sloan answered 28/1, 2020 at 8:8 Comment(0)
J
0

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.

Judsonjudus answered 28/3, 2020 at 9:45 Comment(0)
A
0

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);
            }
Adanadana answered 30/5, 2020 at 6:47 Comment(0)
F
0

In my case, you must be following an android jetpack for a camera course in here [https://developer.android.com/codelabs/camerax-getting-started#0][1]

After that, change the companion object like this.

companion object {
    private const val TAG = "CameraXBasic"
    private const val FILENAME_FORMAT = "yyyy-MM-dd-HH-mm-ss-SSS"
    private const val REQUEST_CODE_PERMISSIONS = 10
    private val REQUIRED_PERMISSIONS = arrayOf(Manifest.permission.CAMERA)
}

Don't forget to add permission to access storage in the manifest.xml

Favour answered 3/6, 2021 at 6:29 Comment(0)
D
0

In my case, the cause of the problem is that the surfaceTexture is available before the ui is not ready. To solve it, i add some delay (i don't know whether it is the correct solution or not, but it's working).

@Override
public void onSurfaceTextureAvailable(SurfaceTexture surfaceTexture, int arg1, int arg2) {
    mSurfaceTexture = surfaceTexture;
    try {
        Thread.sleep(200); // add some delay
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    cameraHelper.openCamera(mSurfaceTexture);
}
Desired answered 27/11, 2022 at 7:46 Comment(2)
No, it's not correct. Do not EVER use delays in UI apps in production. Because it fixes nothing. For example, take another more slow device and you'll see the error again. But now it's much more frustrating to find the cause.Karachi
@EvgeniiVorobei you are right. However i am developing an application for a single device and this solution is enough for me.Literal

© 2022 - 2024 — McMap. All rights reserved.