hsiafan/apk-parser

NPE when parsing due to invalid adaptive icon

Opened this issue · 0 comments

Happens with the latest version 2.6.9.

I had the following code:
Optional<IconFace> iconFile = apkFile.getAllIcons().stream().filter(IconFace::isFile).findFirst();

This crashed with a NullPointerExceptionwhen checking isFile. Reason: getAllIcons() returns an AdaptiveIcon instance. However, both foreground and background icons in this instance are null. The public methods are apparently just using the foreground icon anyway but do not check for null objects, hence the crash.

In my opinion getAllIcons() should not return an icon instance if it is actually not a valid icon (doing null checks would just be a workaround). I expect the bug at the time of the AdaptiveIcon instanciation: the APK definitely has an icon and is also accepted in the Google Play Store.

Unfortunately I cannot share the APK for to confidentiality reasons, sorry!