Skip to content

callback compatibility issue when initialing method #235

@PSDroid2022

Description

@PSDroid2022

We confirm a callback compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.

In ''MFBResources", you super the framework API "<android.content.res.Resources: int getColor(int,android.content.res.Resources.Theme)>" in "getColor" method as shown in following. But actually, this method is added in API level 23 (https://developer.android.google.cn/reference/android/content/res/Resources?hl=en#getColor(int,%20android.content.res.Resources.Theme)).

@Override
	public int getColor(int id, Theme theme) throws NotFoundException {
        switch (getResourceEntryName(id)) {
            case "colorPrimary":
                return MFB.colorPrimary;
            case "colorPrimaryDark":
                return MFB.colorPrimaryDark;
            case "colorAccent":
                return MFB.colorAccent;
            default:
                return super.getColor(id, theme);
        }
    }

So when the app try to initial related Toast on devices level 17 - 23, your app will run with an unpredictable results.

We suggest you:

  1. super this API on sdk version <23, getColor (int id) (https://developer.android.google.cn/reference/android/content/res/Resources?hl=en#getColor(int))
  2. add an "if(SDK_INT>22)", " @TargetApi(Build.VERSION_CODES.M)" or change your app miniSDK from 17 to 23 to fix this potential issue.
    By the way, "@TargetApi(Build.VERSION_CODES.M)" will be deleted by Android compiler when extracting APKs, so it seems like a not good way to solve those issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions