kabouzeid / Phonograph

A material designed music player for Android
GNU General Public License v3.0
2.73k stars 731 forks source link

An Incompatible API Usages in APP of "<android.content.Context: int getColor(int)>" #950

Open PSDroid2022 opened 2 years ago

PSDroid2022 commented 2 years ago

For your app, we have found that this project has accessed the following APIs which are available only on an API level higher than the declared minSdkVersion and which are accessed without proper protection. In other words, if those APIs get called at runtime, it will trigger a NoSuchMethodError and thus result in a crash of the running application.

<android.content.Context: int getColor(int)>: [23,30]

Error path: <com.kabouzeid.gramophone.ui.activities.SettingsActivity$SettingsFragment: boolean lambda$invalidateSettings$7$SettingsActivity$SettingsFragment(androidx.preference.Preference,java.lang.Object)>[[]]--><com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager: void <init>(android.content.Context)>[]--><com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager: void initDynamicShortcuts()>[[]]--><com.kabouzeid.gramophone.appshortcuts.DynamicShortcutManager: java.util.List getDefaultShortcuts()>[[]]--><com.kabouzeid.gramophone.appshortcuts.shortcuttype.ShuffleAllShortcutType: void <init>(android.content.Context)>[]--><com.kabouzeid.gramophone.appshortcuts.shortcuttype.ShuffleAllShortcutType: android.content.pm.ShortcutInfo getShortcutInfo()>[[]]--><com.kabouzeid.gramophone.appshortcuts.AppShortcutIconGenerator: android.graphics.drawable.Icon generateThemedIcon(android.content.Context,int)>[[]]--><com.kabouzeid.gramophone.appshortcuts.AppShortcutIconGenerator: androidx.core.graphics.drawable.IconCompat generateDefaultThemedIcon(android.content.Context,int)>[[]]--><android.content.Context: int getColor(int)>
Error path: <com.kabouzeid.gramophone.App: void <init>()>[[]]--><android.content.Context: void <init>()>[]--><android.content.Context: int getColor(int)>

You can add an if-then check like "If(Build.VERSION.SDK_INT >= 23)" when invoking this API to prevent compatibility issues.