adolfintel / OpenPods

The Free and Open Source app for monitoring your AirPods on Android
https://fdossena.com/?p=openPods/index.frag
GNU General Public License v3.0
932 stars 161 forks source link

Crash when location_disabled_*.xml should be displayed. #93

Closed SebiderSushi closed 4 years ago

SebiderSushi commented 4 years ago

I am experiencing a strange crash when location is disabled.
It seems as if the new dimens resource is unavailable. I can reproduce this isse when building from revision f6a39854afcd1463badea8f91f671787d3064f35 with AndroidStudio as well.

App version: 1.4 (F-Droid); version 1.3 is unaffected. Device: Xiaomi Redmi 4X ROM: Lineage 15.1 (Oreo), ResurrectionRemix 7.0.2 (Pie)

Logcat ``` 06-16 04:08:20.327 1439 4218 W ResourceType: For resource 0x7f050064, entry index(100) is beyond type entryCount(62) 06-16 04:08:20.327 1439 4218 W ResourceType: Failure getting entry for 0x7f050064 (t=4 e=100) (error -75) 06-16 04:08:20.327 1439 4216 W ResourceType: For resource 0x7f050065, entry index(101) is beyond type entryCount(62) 06-16 04:08:20.327 1439 4216 W ResourceType: Failure getting entry for 0x7f050065 (t=4 e=101) (error -75) 06-16 04:08:20.329 1439 1439 W ResourceType: For resource 0x7f050064, entry index(100) is beyond type entryCount(62) 06-16 04:08:20.329 1439 1439 W ResourceType: Failure getting entry for 0x7f050064 (t=4 e=100) (error -75) 06-16 04:08:20.330 1439 1439 E StatusBar: couldn't inflate view for notification com.dosse.airpods/0x1 06-16 04:08:20.330 1439 1439 E StatusBar: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: You must supply a layout_height attribute. 06-16 04:08:20.330 1439 1439 E StatusBar: Caused by: java.lang.UnsupportedOperationException: Binary XML file line #2: You must supply a layout_height attribute. 06-16 04:08:20.330 1439 1439 E StatusBar: at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:775) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:7555) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:7746) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.widget.FrameLayout$LayoutParams.(FrameLayout.java:439) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:370) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:368) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.view.LayoutInflater.inflate(LayoutInflater.java:502) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.widget.RemoteViews.inflateView(RemoteViews.java:3498) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.widget.RemoteViews.-wrap1(Unknown Source:0) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.widget.RemoteViews$AsyncApplyTask.doInBackground(RemoteViews.java:3600) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.widget.RemoteViews$AsyncApplyTask.doInBackground(RemoteViews.java:3596) 06-16 04:08:20.330 1439 1439 E StatusBar: at android.os.AsyncTask$2.call(AsyncTask.java:333) 06-16 04:08:20.330 1439 1439 E StatusBar: at java.util.concurrent.FutureTask.run(FutureTask.java:266) 06-16 04:08:20.330 1439 1439 E StatusBar: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 06-16 04:08:20.330 1439 1439 E StatusBar: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 06-16 04:08:20.330 1439 1439 E StatusBar: at java.lang.Thread.run(Thread.java:764) 06-16 04:08:20.331 1439 1439 W StatusBar: removeNotification for unknown key: 0|com.dosse.airpods|1|null|10136 06-16 04:08:20.332 1264 2816 D NotificationService: onNotification error pkg=com.dosse.airpods tag=null id=1; will crashApplication(uid=10136, pid=4445) 06-16 04:08:20.334 4445 4445 D AndroidRuntime: Shutting down VM 06-16 04:08:20.335 4445 4445 E AndroidRuntime: FATAL EXCEPTION: main 06-16 04:08:20.335 4445 4445 E AndroidRuntime: Process: com.dosse.airpods, PID: 4445 06-16 04:08:20.335 4445 4445 E AndroidRuntime: android.app.RemoteServiceException: Bad notification posted from package com.dosse.airpods: Couldn't inflate contentViewsandroid.view.InflateException: Binary XML file line #2: Binary XML file line #2: You must supply a layout_height attribute. ```
adolfintel commented 4 years ago

@Electric1447 I don't see anything wrong with the XML or the code. Could this be an androidx bug?

Electric1447 commented 4 years ago

Possibly, however location should never be disabled.

Electric1447 commented 4 years ago

@SebiderSushi try to hardcode the layouts height and see if it crashes

SebiderSushi commented 4 years ago

Yes it does not happen when hardcoding the layout height. Was anyone else able to reproduce this as well?

SebiderSushi commented 4 years ago

As per the code, Android Studio itself successfully resolves the values for the dimens resources as well here on my side so that should probably not be the issue.

Electric1447 commented 4 years ago

Yes it does not happen when hardcoding the layout height. Was anyone else able to reproduce this as well?

No

Electric1447 commented 4 years ago

The weirdest part is that you use an Lineage based roms so these things should not happen

adolfintel commented 4 years ago

Android at its finest. I'm fine with hardcoding those sizes but I can't find anyone with this issue online, it's kinda weird.

Electric1447 commented 4 years ago

@adolfintel I really thing we should compile a list of bugs relating to the Android OS and report them to Google

Electric1447 commented 4 years ago

As per the code, Android Studio itself successfully resolves the values for the dimens resources as well here on my side so that should probably not be the issue.

I didn't quite understand what you mean in here could you please elaborate?

adolfintel commented 4 years ago

@adolfintel I really thing we should compile a list of bug relating to the Android OS and report them to Google

Yeah, probably. I will be abandoning android as soon as linux phones are viable though. I've been developing on android since 2012 and it's been nothing but trouble.

adolfintel commented 4 years ago

As per the code, Android Studio itself successfully resolves the values for the dimens resources as well here on my side so that should probably not be the issue.

I didn't quite understand what you mean in here could you please elaborate?

I think he means that android studio displays width and height correctly (grabs them from dimens.xml), but for some reason the app itself does not. Decompiling the APK might give us a clue about what's going on.

Electric1447 commented 4 years ago

Jadx-gui is the best decompilation tool for Android

Electric1447 commented 4 years ago

I decompiled the app and everything seems fine

Electric1447 commented 4 years ago

Maybe try to change the layout height of the textview to be the same as his parent?

adolfintel commented 4 years ago

I don't know, it points at line 2, that's the RelativeLayout tag. Maybe we could try another type of layout. This notification is so simple, any layout would be fine.

Electric1447 commented 4 years ago

From the log 0x7f050065 is noti_location_small_height and 0x7f050064 is noti_location_big_height

Electric1447 commented 4 years ago

@SebiderSushi do you have any theme installation (Layers, substratum, ect)?

Context: https://reddit.com/r/Nexus6P/comments/4doysy/if_you_are_still_using_inversion_ui_or_any_layers

Electric1447 commented 4 years ago

I don't know, it points at line 2, that's the RelativeLayout tag. Maybe we could try another type of layout. This notification is so simple, any layout would be fine.

ConstraintLayout?

adolfintel commented 4 years ago

That should be perfectly fine

SebiderSushi commented 4 years ago

@SebiderSushi do you have any theme installation (Layers, substratum, ect)?

Context: https://reddit.com/r/Nexus6P/comments/4doysy/if_you_are_still_using_inversion_ui_or_any_layers

Not that i know of. If yes, then it would have to be something preinstalled.

And for the following observation stated in the reddit post:

But the resource would change around every minute and the index along with that

I just reproduced the crash and the resource identifier hex values and indexes are the same as in the logcat i posted in my OP.

Electric1447 commented 4 years ago

Could you change RelativeLayout to ConstraintLayout and retest?

SebiderSushi commented 4 years ago

No i don't like ConstraintLayout i'm a LinearLayout guy.

Okay jokes aside, i can reproduce the crash with both ConstraintLayout and LinearLayout as well.

adolfintel commented 4 years ago

@Electric1447 I think the best way to workaround this problem at the moment is to hardcode width and height in the notifications (all variants). I would also like to try to get rid of androidx to see if that's the cause of the problem. It's just an experiment and I'll do it myself.

Electric1447 commented 4 years ago

I am pretty sure we cannot hardcode width with notifications, and we should test if that is really the issue

Electric1447 commented 4 years ago

Pretty sure this doesn't releate to jetpack (androidx) as they did not change RelativeLayout and TextView

Electric1447 commented 4 years ago

@SebiderSushi send me the link to the XDA thread of your rom although I highly doubt that's the issue

adolfintel commented 4 years ago

Yeah, you're right, only the height needs to be hardcoded. The width is determined automatically.

Electric1447 commented 4 years ago

https://developer.android.com/training/notify-user/custom-notification trying to dig in here to see if something is related to this

SebiderSushi commented 4 years ago

strange tidbit: if i mangle the Main Activity like so, the layout works just fine even with dynamic dimens:

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.location_disabled_small);
    }
SebiderSushi commented 4 years ago

@SebiderSushi send me the link to the XDA thread of your rom although I highly doubt that's the issue

The ResurrectionRemix 7.0.2 ROM is: https://forum.xda-developers.com/xiaomi-redmi-4x/development/rom-unofficial-resurrection-remix-t3912521

The LineageOS 15.1 ROM is actually self-build, with a few modifcations.

I'll try with official LineageOS 16.0 and maybe a few other ROMs.

Electric1447 commented 4 years ago

@SebiderSushi send me the link to the XDA thread of your rom although I highly doubt that's the issue

The ResurrectionRemix 7.0.2 ROM is: https://forum.xda-developers.com/xiaomi-redmi-4x/development/rom-unofficial-resurrection-remix-t3912521

The LineageOS 15.1 ROM is actually self-build, with a few modifcations.

I'll try with official LineageOS 16.0 and maybe a few other ROMs.

LuisROM is stable so that's not relevant.

Electric1447 commented 4 years ago

At least we got that out of the way

Electric1447 commented 4 years ago

This is a shot in the dark but try to change noti_location_small_height to 64dp

adolfintel commented 4 years ago

Here's a test APK without androidx. The layout will be all fucked up. If this version works, I'll fix it. app-release.zip

SebiderSushi commented 4 years ago

This is a shot in the dark but try to change noti_location_small_height to 64dp

Can still reproduce the bug with that...

SebiderSushi commented 4 years ago

Here's a test APK without androidx. The layout will be all fucked up. If this version works, I'll fix it. app-release.zip

This one still crashed as soon as i disable location, same error : /

06-16 17:20:23.861  1454  1454 E StatusBar: couldn't inflate view for notification com.dosse.airpods/0x1
06-16 17:20:23.861  1454  1454 E StatusBar: android.view.InflateException: Binary XML file line #2: Binary XML file line #2: You must supply a layout_height attribute.
06-16 17:20:23.861  1454  1454 E StatusBar: Caused by: java.lang.UnsupportedOperationException: Binary XML file line #2: You must supply a layout_height attribute.
adolfintel commented 4 years ago

Good to know, it would have been quite annoying if androidx was the cause. @Electric1447 Let's just hardcode the height of all notifications, ok?

SebiderSushi commented 4 years ago

What a ride... :D

Electric1447 commented 4 years ago

wait it doesnt crashes when hardcoded?

adolfintel commented 4 years ago

This is exactly why I hate android development. I swear, every single API in that fucking system is broken on at least 1 phone

SebiderSushi commented 4 years ago

And not to forget the system upgrade model...

adolfintel commented 4 years ago

Yes it does not happen when hardcoding the layout height.

@Electric1447

Electric1447 commented 4 years ago

ok

Electric1447 commented 4 years ago

I'll make a commit

SebiderSushi commented 4 years ago

Since i tested this now, i'm still gonna state for the record that the crash also appeared with the official lineage-16.0-20200610-nightly-santoni-signed.zip.

Thanks for fixing and for investing yourself so much into this issue :)