googlesamples / easypermissions

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

Crash when go back to app after disable permission on Settings #275

Closed lhtriet closed 5 years ago

lhtriet commented 5 years ago

Describe the problem

After allowing permission by using easypermissions, I go to Settings to disable (any) permission, go back to app, it will crash without any log.

Code and logs

private fun askAudioPermission(conversationWrapper: ConversationWrapper) {
    if (EasyPermissions.hasPermissions(this, Manifest.permission.RECORD_AUDIO)) {
        newConversationDetailViewModel.withState {
            if (conversationWrapper.otherContact != null) {
                startActivity(CallActivity.newIntent(this@NewConversationDetailActivity, this.conversationWrapper?.peekData()?.otherContact!!, CallType.AUDIO))
            }
        }
    } else {
        EasyPermissions.requestPermissions(
                PermissionRequest.Builder(this, Constants.REQUEST_AUDIO, Manifest.permission.RECORD_AUDIO)
                        .setRationale(R.string.permission_audio)
                        .setNegativeButtonText(R.string.deny)
                        .setPositiveButtonText(R.string.allow)
                        .setTheme(R.style.Theme_AppCompat_Light_Dialog_Alert)
                        .build())
    }

}

samtstern commented 5 years ago

@lhtriet it will crash without any log. is not really possible. If your app crashes there will definitely be an entry in the logcat.

lhtriet commented 5 years ago

Sorry, this is the error log: 2019-02-27 10:23:09.570 11552-11552/io.aioz.cryptochat E/AndroidRuntime: FATAL EXCEPTION: main Process: io.aioz.cryptochat, PID: 11552 java.lang.RuntimeException: Unable to start activity ComponentInfo{io.aioz.cryptochat/io.aioz.cryptochat.ui.main.conversations.newConversationDetail.NewConversationDetailActivity}: java.lang.IllegalArgumentException: No injector factory bound for Class at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2957) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6944) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) Caused by: java.lang.IllegalArgumentException: No injector factory bound for Class at dagger.android.DispatchingAndroidInjector.inject(DispatchingAndroidInjector.java:136) at dagger.android.AndroidInjection.inject(AndroidInjection.java:59) at io.aioz.base.activity.BaseActivity.onCreate(BaseActivity.kt:51) at io.aioz.cryptochat.ui.main.conversations.newConversationDetail.NewConversationDetailActivity.onCreate(NewConversationDetailActivity.kt:323) at android.app.Activity.performCreate(Activity.java:7183) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)

samtstern commented 5 years ago

@lhtriet there is no mention of EasyPermissions in that stack trace it all. It seems like your application has some issues with how it resumes:

java.lang.RuntimeException: Unable to start activity ComponentInfo{io.aioz.cryptochat/io.aioz.cryptochat.ui.main.conversations.newConversationDetail.NewConversationDetailActivity}: java.lang.IllegalArgumentException: No injector factory bound for Class<io.aioz.cryptochat.ui.main.conversations.newConversationDetail.NewConversationDetailActivity>

I'd suggest asking on StackOverflow for some general help debugging this.

tmac1999 commented 4 years ago

It is because after Android 6.0, when you put APP in background and go to Setting ,disable the permission ,the APP will be terminated.