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

Crash with DrawerLayout when getting permissions #106

Open
Pirokar opened this issue Jun 21, 2022 · 3 comments
Open

Crash with DrawerLayout when getting permissions #106

Pirokar opened this issue Jun 21, 2022 · 3 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@Pirokar
Copy link

Pirokar commented Jun 21, 2022

Crash with permissions modal window appearing (android 12, sumsung galaxy note 10+, beagle: 2.8.2):
E/AndroidRuntime: FATAL EXCEPTION: main Process: io.edna.threads.demo, PID: 2113 java.lang.IllegalArgumentException: DrawerLayout must be measured with MeasureSpec.EXACTLY. at androidx.drawerlayout.widget.DrawerLayout.onMeasure(DrawerLayout.java:1090) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:145) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552) at android.widget.LinearLayout.measureVertical(LinearLayout.java:842) at android.widget.LinearLayout.onMeasure(LinearLayout.java:721) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1552) at android.widget.LinearLayout.measureVertical(LinearLayout.java:842) at android.widget.LinearLayout.onMeasure(LinearLayout.java:721) at android.view.View.measure(View.java:27129) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7980) at android.widget.FrameLayout.onMeasure(FrameLayout.java:197) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:1277) at android.view.View.measure(View.java:27129) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:4528) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:3193) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3525) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2911) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10458) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1108) at android.view.Choreographer.doCallbacks(Choreographer.java:866) at android.view.Choreographer.doFrame(Choreographer.java:797) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1092) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:226) at android.os.Looper.loop(Looper.java:313) at android.app.ActivityThread.main(ActivityThread.java:8663) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

@pandulapeter
Copy link
Owner

Hi,

I have the exact same test device and I didn't see this issue yet. Googling the exception, maybe it has something to do with the type of Activity?

Can you find out which Activity is crashing, is it from your code or from somewhere else?

If you figure out for example its package name, you could disable Beagle for that Activity to fix the crash, like this:

Beagle.initialize(
    application = this,
    behavior = Behavior(
        shouldAddDebugMenu = { fragmentActivity -> fragmentActivity.packageName != "the.package.name.for.the.activity" }
    )
)

Let me know if a third party Activity is causing the problem so that I can add it to the library's internal list of excluded activities.

Hopefully this will solve the problem!

@pandulapeter pandulapeter self-assigned this Jun 21, 2022
@pandulapeter pandulapeter added the bug Something isn't working label Jun 21, 2022
@Pirokar
Copy link
Author

Pirokar commented Jun 21, 2022

I've made "Beagle.initialize(...)" in Application class. Activity is just instance of AppCompatActivity
Maybe this could help to create the fix: https://stackoverflow.com/questions/31746072/drawerlayout-must-be-measured-with-measurespec-exactly-error ?

@pandulapeter
Copy link
Owner

I cannot reproduce this crash. I'm using the same device, same Android version and same Beagle version. I tried requesting the Camera permission from a Fragment, and I also tried it in the onCreate() of an Activity, but for me it's working as expected.

Are you maybe using a third party library to handle permissions? From the StackOverflow thread you linked, one possible reason could be an Activity that has a Fullscreen theme / a Dialog activity, maybe that library is inserting an invisible Activity to handle the callbacks from the permission prompt (in that case you could exclude it from Beagle as per my previous comment).

The Drawer from Beagle's side is definitely match_parent, otherwise we'd see this crash a lot more often.

Let me know if you have any other repro steps! Maybe, if you have the time, try to reproduce it on this repository, there is a demo app in the app module (if you manage to do so, feel free to create a PR so that I can test and fix the problem, if it is indeed coming from the library).

@pandulapeter pandulapeter added the question Further information is requested label Jul 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants