eltos / SimpleDialogFragments

An Android library to create dialogs with ease and handle user interaction reliably, using fragments and material design.
Apache License 2.0
119 stars 17 forks source link

Resources$NotFoundException if app is installed from "rogue" app store #88

Closed mtotschnig closed 1 year ago

mtotschnig commented 1 year ago

I have seen the following report where icon ic_clear_search used in ClearableEditText is missing from an APK:

android.content.res.Resources$NotFoundException: Resource ID #0x7f0800ed
       at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:428)
       at android.content.res.Resources.getDrawableForDensity(Resources.java:993)
       at android.content.res.Resources.getDrawable(Resources.java:933)
       at android.content.res.Resources.getDrawable(Resources.java:908)
       at eltos.simpledialogfragment.list.ClearableEditText.init(ClearableEditText.java:180)
       at eltos.simpledialogfragment.list.ClearableEditText.<init>(ClearableEditText.java:73)
       at java.lang.reflect.Constructor.newInstance0(Constructor.java)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
       at android.view.LayoutInflater.createView(LayoutInflater.java:864)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
       at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:971)
       at android.view.LayoutInflater.rInflate(LayoutInflater.java:1133)
       at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1094)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:692)
       at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
       at com.android.internal.policy.HwPhoneLayoutInflater.inflate(HwPhoneLayoutInflater.java:138)
       at eltos.simpledialogfragment.CustomViewDialog.inflate(CustomViewDialog.java:222)
       at eltos.simpledialogfragment.CustomViewDialog.inflate(CustomViewDialog.java:202)
       at eltos.simpledialogfragment.list.CustomListDialog.onCreateContentView(CustomListDialog.java:344)
       at eltos.simpledialogfragment.CustomViewDialog.onCreateDialog(CustomViewDialog.java:261)
       at androidx.fragment.app.DialogFragment.prepareDialog(DialogFragment.java:930)
       at androidx.fragment.app.DialogFragment.onGetLayoutInflater(DialogFragment.java:844)
       at androidx.fragment.app.Fragment.performGetLayoutInflater(Fragment.java:1755)
       at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:527)
       at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:272)
       at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1943)
       at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1845)
       at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1782)
       at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:565)
       at android.os.Handler.handleCallback(Handler.java:900)
       at android.os.Handler.dispatchMessage(Handler.java:103)
       at android.os.Looper.loop(Looper.java:219)
       at android.app.ActivityThread.main(ActivityThread.java:8668)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

This report is from a user that has installed the APK via Aurora (which as far as I know scrapes APK from Play Store), but the underlying reason is that Play Store builds optimized APKs from App bundles and only includes resources needed for a specific device. So I am wondering if this couldn't also happen for users downloading the app directly from Play Store, because ic_clear_search is only included in this library in the hdpi, mdpi, xhdpi folders. Could this icon be migrated to use a vector drawable?

eltos commented 1 year ago

If an icon of a specific density is not available, android choses another density and re-scales. I don't know exactly about the optimisation algorithm of Google Play, but since this is a standard icon I suspect it might remove it completely and re-add it later. This sounds like that other app store is to blame, especially since I'm sure Google does not allow scraping their appstore.

Anyways, using a vector drawable is preferable in any case 👍