MaterialFBook
MaterialFBook copied to clipboard
callback compatibility issue when initialing method
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:
- super this API on sdk version <23, getColor (int id) (https://developer.android.google.cn/reference/android/content/res/Resources?hl=en#getColor(int))
- 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.