Access denied for property "vendor.camera.aux.packagelist"
Solution 1
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); }
Solution 2
I had this in my android manifest that prevented the app from using the camera.
android:hardwareAccelerated="false"
Removing it helped me.
Solution 3
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";
Solution 4
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();
}
});
}
Comments
-
Andre over 2 years
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 }
-
Karolina Hagegård about 3 yearsWhere in the project do you put that
if
statement, please? -
GiridharaSPK about 3 years@KarolinaHagegård Conventionally we do that in Splash Activity, when requesting permissions in Native Android development
-
Karolina Hagegård about 3 yearsOk... 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.