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

callback compatibility issue when initialing method #235

Open
PSDroid2022 opened this issue Mar 16, 2022 · 0 comments
Open

callback compatibility issue when initialing method #235

PSDroid2022 opened this issue Mar 16, 2022 · 0 comments

Comments

@PSDroid2022
Copy link

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant