googlesamples / easypermissions

Simplify Android M system permissions
https://firebaseopensource.com/projects/googlesamples/easypermissions/
Apache License 2.0
9.87k stars 1.46k forks source link

Crash when deny permissions. #291

Closed yanjiepeng closed 4 years ago

yanjiepeng commented 4 years ago

Basic Information

Device type:SAMSUNG G9200 ,HUAWEI Honor8 Lite OS version: Android7.0 Android 8.0 EasyPermissions version: 2.0.0 and 2.0.1

Describe the problem

Crash when deny permissions. I have already tested two situations:

  1. Turn off camera permission in system settings.
  2. deny the camera permission when the first request. restart App it will crash.

Code and logs

Code:

 private void requestCodeQRCodePermissions() {
        String[] perms = {Manifest.permission.CAMERA, Manifest.permission.WRITE_EXTERNAL_STORAGE};
        if (!EasyPermissions.hasPermissions(this, perms)) {
//            EasyPermissions.requestPermissions(this, getString(R.string.allow_camera_permission), REQUEST_CODE_QRCODE_PERMISSIONS, perms);

            EasyPermissions.requestPermissions(new PermissionRequest.Builder(this, REQUEST_CODE_QRCODE_PERMISSIONS, perms)
                    .setRationale(R.string.allow_camera_permission)
                    .setPositiveButtonText(R.string.dialog_ok)
                    .setNegativeButtonText(R.string.dialog_cancel)
                    .setTheme(R.style.dialog)
                    .build());

        }
    }

logs:

 Process: com.tazan.cd.streetlight, PID: 18825
    java.lang.NoSuchMethodError: No virtual method isStateSaved()Z in class Landroid/support/v4/app/FragmentManager; or its super classes (declaration of 'android.support.v4.app.FragmentManager' appears in /data/app/com.tazan.cd.streetlight-sc-sX-rNCVNlO4qWt3BQkw==/base.apk:classes20.dex)
        at pub.devrel.easypermissions.RationaleDialogFragmentCompat.showAllowingStateLoss(RationaleDialogFragmentCompat.java:48)
        at pub.devrel.easypermissions.helper.BaseSupportPermissionsHelper.showRequestPermissionRationale(BaseSupportPermissionsHelper.java:43)
        at pub.devrel.easypermissions.helper.PermissionHelper.requestPermissions(PermissionHelper.java:66)
        at pub.devrel.easypermissions.EasyPermissions.requestPermissions(EasyPermissions.java:148)
        at com.tazan.cd.streetlight.activity.MainActivity.requestCodeQRCodePermissions(MainActivity.java:615)
        at com.tazan.cd.streetlight.activity.MainActivity.onStart(MainActivity.java:553)
        at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1339)
        at android.app.Activity.performStart(Activity.java:7392)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3157)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3302)
        at android.app.ActivityThread.-wrap12(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891)
        at android.os.Handler.dispatchMessage(Handler.java:108)
        at android.os.Looper.loop(Looper.java:166)
        at android.app.ActivityThread.main(ActivityThread.java:7425)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

compileSdkVersion 27

// TODO(you): show the code that produces the problem,
//            and any relevant logs.