Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalAccessException: Unable to open camera in Emulator Android 11 #25

Open
spungkyb opened this issue Nov 2, 2020 · 1 comment

Comments

@spungkyb
Copy link

spungkyb commented Nov 2, 2020

java.lang.IllegalAccessException: Unable to open camera i can open camera, how solve this?

@hamidsamirabad
Copy link

hamidsamirabad commented Dec 23, 2021

i have this issue, it depends on SdkVersion not your android version, if its more than 29 , this library doesn't work

compileSdk 29

defaultConfig {
    targetSdk 29
  }

so how fix it on new sdks :

you must download the code and copy it to your poroject
and in class Camera
comment this codes
and run your project successfully

public void takePicture() throws NullPointerException, IllegalAccessException {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
switch (mode) {
case ACTIVITY:
// if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
setUpIntent(takePictureIntent);
activity.startActivityForResult(takePictureIntent,REQUEST_TAKE_PHOTO);
// } else {
// throw new IllegalAccessException("Unable to open camera");
// }

or change to this

public void takePicture() throws NullPointerException, IllegalAccessException {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    switch (mode) {
        case ACTIVITY:
            try {
                setUpIntent(takePictureIntent);
                activity.startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
            }catch (Exception ex){
                  throw new IllegalAccessException("Unable to open camera");
             }
        
            break;

ridwanharts added a commit to ridwanharts/ParaCamera that referenced this issue Feb 9, 2023
- Android Gradle Plugin Version 7.3.1
- Gradle Version 7.6
- compileSdkVersion 33
- targetSdkVersion 33
- Tested on Virtual Device Android API 33
- Change code based on issue :
java.lang.IllegalAccessException: Unable to open camera i can open camera
based on  hamidsamirabad comment : janishar#25 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants